File tree 2 files changed +19
-1
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -1896,7 +1896,10 @@ class Namer { typer: Typer =>
1896
1896
*/
1897
1897
def expectedDefaultArgType =
1898
1898
val originalTp = defaultParamType
1899
- val approxTp = wildApprox(originalTp)
1899
+ val approxTp = withMode(Mode .TypevarsMissContext ):
1900
+ // assert TypevarsMissContext so that TyperState does not leak into approximation
1901
+ // We approximate precisely because we want to unlink the type variable. Test case is i18795.scala.
1902
+ wildApprox(originalTp)
1900
1903
approxTp.stripPoly match
1901
1904
case atp @ defn.ContextFunctionType (_, resType)
1902
1905
if ! defn.isNonRefinedFunction(atp) // in this case `resType` is lying, gives us only the non-dependent upper bound
Original file line number Diff line number Diff line change
1
+ package example
2
+
3
+ object Main extends App with Test {
4
+ load(" " )()
5
+ }
6
+
7
+ trait Test {
8
+
9
+ def load [T ](
10
+ doLoad : T
11
+ )(
12
+ description : T => Option [String ] = (x : T ) => None // <--- compile error here
13
+ ): Unit = ???
14
+
15
+ }
You can’t perform that action at this time.
0 commit comments