Skip to content

Commit 9ae3a1f

Browse files
committed
improve the fix to support more general cases
1 parent 1a20c5b commit 9ae3a1f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ object Implicits {
6060

6161
/** Return those references in `refs` that are compatible with type `pt`. */
6262
protected def filterMatching(pt: Type)(implicit ctx: Context): List[Candidate] = track("filterMatching") {
63+
val ptNorm = normalize(pt, pt) // `pt` could be implicit function types, check i2749
6364

6465
def refMatches(ref: TermRef)(implicit ctx: Context) = /*ctx.traceIndented(i"refMatches $ref $pt")*/ {
6566

@@ -124,8 +125,7 @@ object Implicits {
124125
false
125126
}
126127
else
127-
NoViewsAllowed.isCompatible(normalize(ref, pt), pt) ||
128-
NoViewsAllowed.isCompatible(ref, pt) // `pt` could be an implicit function type, check i2749
128+
NoViewsAllowed.isCompatible(normalize(ref, pt), ptNorm)
129129
}
130130
}
131131

tests/pos/i2749.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,19 @@ object Test {
55

66
f : Boolean
77
}
8+
9+
object Test2 {
10+
val f: implicit (implicit Int => Char) => Boolean = ???
11+
implicit val s: String = null
12+
implicit val g: implicit Int => implicit String => Char = ???
13+
14+
f : Boolean
15+
}
16+
17+
object Test3 {
18+
val f: implicit (implicit Int => implicit String => Char) => Boolean = ???
19+
implicit val n: Int = 3
20+
implicit val g: implicit Int => Char = ???
21+
22+
f : Boolean
23+
}

0 commit comments

Comments
 (0)