Skip to content

Commit 1a20c5b

Browse files
committed
fix #2749: support implicit resolution of implicit function types
1 parent 243e439 commit 1a20c5b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ object Implicits {
123123
record("discarded eligible")
124124
false
125125
}
126-
else NoViewsAllowed.isCompatible(normalize(ref, pt), pt)
126+
else
127+
NoViewsAllowed.isCompatible(normalize(ref, pt), pt) ||
128+
NoViewsAllowed.isCompatible(ref, pt) // `pt` could be an implicit function type, check i2749
127129
}
128130
}
129131

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
16401640
if (defn.isImplicitFunctionType(pt) &&
16411641
xtree.isTerm &&
16421642
!untpd.isImplicitClosure(xtree) &&
1643+
!ctx.mode.is(Mode.ImplicitShadowing) &&
16431644
!ctx.isAfterTyper)
16441645
makeImplicitFunction(xtree, pt)
16451646
else xtree match {

tests/pos/i2749.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
object Test {
2+
val f: implicit (implicit Int => Char) => Boolean = ???
3+
implicit val n: Int = 3
4+
implicit val g: implicit Int => Char = ???
5+
6+
f : Boolean
7+
}

0 commit comments

Comments
 (0)