Skip to content

Commit 6f68143

Browse files
authored
Merge pull request #3428 from dotty-staging/fix-3422
Fix #3422: Add missing case to TypeComparer
2 parents 572b025 + 1445481 commit 6f68143

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,18 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
369369
case _ =>
370370
val cls2 = tp2.symbol
371371
if (cls2.isClass) {
372-
val base = tp1.baseType(cls2)
373-
if (base.exists) {
374-
if (cls2.is(JavaDefined))
375-
// If `cls2` is parameterized, we are seeing a raw type, so we need to compare only the symbol
376-
return base.typeSymbol == cls2
377-
if (base ne tp1) return isSubType(base, tp2)
372+
if (cls2.typeParams.nonEmpty && tp1.isHK)
373+
isSubType(tp1, EtaExpansion(cls2.typeRef))
374+
else {
375+
val base = tp1.baseType(cls2)
376+
if (base.exists) {
377+
if (cls2.is(JavaDefined))
378+
// If `cls2` is parameterized, we are seeing a raw type, so we need to compare only the symbol
379+
return base.typeSymbol == cls2
380+
if (base ne tp1) return isSubType(base, tp2)
381+
}
382+
if (cls2 == defn.SingletonClass && tp1.isStable) return true
378383
}
379-
if (cls2 == defn.SingletonClass && tp1.isStable) return true
380384
}
381385
fourthTry(tp1, tp2)
382386
}

tests/pos/i3422/a_1.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Fun[L[_]]
2+
3+
object O1 {
4+
trait N[X]
5+
}
6+
7+
object O2 {
8+
def bar: Fun[O1.N] = ???
9+
}

tests/pos/i3422/b_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
def c: Fun[O1.N] = O2.bar
3+
}

0 commit comments

Comments
 (0)