Skip to content

Commit fc225ff

Browse files
committed
Fix #2671: Don't instantiate typevars before creating implicit closure
We were a bit too conservative in instantiating and type variables before creating an implicit closure. This causes unwanted instantiations, see #2671.
1 parent 6472ae3 commit fc225ff

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,8 +1779,7 @@ class Typer extends Namer
17791779

17801780
protected def makeImplicitFunction(tree: untpd.Tree, pt: Type)(implicit ctx: Context): Tree = {
17811781
val defn.FunctionOf(formals, _, true) = pt.dropDependentRefinement
1782-
val paramTypes = formals.map(fullyDefinedType(_, "implicit function parameter", tree.pos))
1783-
val ifun = desugar.makeImplicitFunction(paramTypes, tree)
1782+
val ifun = desugar.makeImplicitFunction(formals, tree)
17841783
typr.println(i"make implicit function $tree / $pt ---> $ifun")
17851784
typed(ifun, pt)
17861785
}

tests/pos/i2671.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Foo {
2+
3+
def map[E](f: implicit E => Int): (implicit E => Int) = ???
4+
5+
implicit def i: Int = ???
6+
7+
def f: implicit Int => Int = ???
8+
9+
val a: Int = map(f)
10+
11+
}

0 commit comments

Comments
 (0)