File tree 3 files changed +15
-5
lines changed
compiler/src/dotty/tools/dotc/typer
3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ object Inferencing {
166
166
case Apply (fn, _) => boundVars(fn, acc)
167
167
case TypeApply (fn, targs) =>
168
168
val tvars = targs.tpes.collect {
169
- case tvar : TypeVar if ! tvar.isInstantiated => tvar
169
+ case tvar : TypeVar if ! tvar.isInstantiated && targs.contains(tvar.bindingTree) => tvar
170
170
}
171
171
boundVars(fn, acc ::: tvars)
172
172
case Select (pre, _) => boundVars(pre, acc)
@@ -399,8 +399,8 @@ trait Inferencing { this: Typer =>
399
399
def uninstBoundVars (tree : Tree )(implicit ctx : Context ): List [TypeVar ] = {
400
400
val buf = new mutable.ListBuffer [TypeVar ]
401
401
tree.foreachSubTree {
402
- case arg : TypeTree =>
403
- arg.tpe match {
402
+ case TypeApply (_, args) =>
403
+ args.tpes.foreach {
404
404
case tv : TypeVar if ! tv.isInstantiated && tree.contains(tv.bindingTree) => buf += tv
405
405
case _ =>
406
406
}
Original file line number Diff line number Diff line change @@ -1970,7 +1970,7 @@ class Typer extends Namer
1970
1970
if (! tree.denot.isOverloaded) {
1971
1971
// for overloaded trees: resolve overloading before simplifying
1972
1972
if (tree.isDef) interpolateUndetVars(tree, tree.symbol, pt)
1973
- else if (! tree.tpe.widen.isInstanceOf [LambdaType ]) interpolateUndetVars(tree, NoSymbol , pt)
1973
+ else if (! tree.tpe.widen.isInstanceOf [MethodOrPoly ]) interpolateUndetVars(tree, NoSymbol , pt)
1974
1974
tree.overwriteType(tree.tpe.simplified)
1975
1975
}
1976
1976
adaptInterpolated(tree, pt)
@@ -2106,8 +2106,10 @@ class Typer extends Namer
2106
2106
def adaptNoArgsImplicitMethod (wtp : MethodType ): Tree = {
2107
2107
assert(wtp.isImplicitMethod)
2108
2108
val tvarsToInstantiate = tvarsInParams(tree)
2109
+ println(i " adaptNoArgsImpl $tvarsToInstantiate%, %, ${ctx.typerState.constraint}" )
2109
2110
wtp.paramInfos.foreach(instantiateSelected(_, tvarsToInstantiate))
2110
2111
val constr = ctx.typerState.constraint
2112
+ println(i " new constr = $constr" )
2111
2113
2112
2114
def dummyArg (tp : Type ) = untpd.Ident (nme.??? ).withTypeUnchecked(tp)
2113
2115
Original file line number Diff line number Diff line change 1
1
object Test {
2
2
def int [A ](k : String => A )(s : String )(x : Int ): A = ???
3
3
4
- // composing directly: ok in scalac, error in dotc
4
+ // composing directly: ok in scalac, now also in dotc
5
5
val c : (String => String ) => (String ) => (Int ) => (Int ) => String = (int[Int => String ](_)).compose(int[String ](_))
6
6
7
7
// unwrapping composition: ok in scalac, ok in dotc
8
8
val q : (String => Int => String ) => (String ) => (Int ) => (Int => String ) = int[Int => String ]
9
9
val p : (String => String ) => (String ) => (Int ) => String = int
10
10
val c2 : (String => String ) => (String ) => (Int ) => (Int ) => String = q.compose(p)
11
+
12
+ class B
13
+ class C extends B
14
+ implicit def iC : C => Unit = ???
15
+
16
+ // making sure A is not instantiated before implicit search
17
+ def f [A ](k : String => A )(s : String )(x : Int )(implicit y : A => Unit ): A = ???
18
+ val r : (String => C ) => (String ) => (Int ) => B = f
11
19
}
You can’t perform that action at this time.
0 commit comments