Skip to content

Commit bec85a9

Browse files
committed
Fix subtyping of types without symbols
1 parent c12f2ea commit bec85a9

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ class TypeComparer(initctx: Context) extends DotClass {
460460
tp1 match {
461461
case tp1: NamedType =>
462462
val sym1 = tp1.symbol
463-
(if (sym1 eq tp2.symbol) (
463+
(if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol)) (
464464
ctx.erasedTypes
465465
|| sym1.isStaticOwner
466466
|| { // Implements: A # X <: B # X

test/dotc/tests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class tests extends CompilerTest {
8787
@Test def neg_t1843 = compileFile(negDir, "t1843", xerrors = 1)
8888
@Test def neg_t1843_variances = compileFile(negDir, "t1843-variances", xerrors = 1)
8989
@Test def neg_t2994 = compileFile(negDir, "t2994", xerrors = 2)
90-
@Test def neg_subtyping = compileFile(negDir, "subtyping", xerrors = 1)
90+
@Test def neg_subtyping = compileFile(negDir, "subtyping", xerrors = 2)
9191
@Test def neg_variances = compileFile(negDir, "variances", xerrors = 2)
9292

9393
@Test def dotc = compileDir(dotcDir + "tools/dotc", twice)

tests/neg/subtyping.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ class B {
44
class A extends B
55

66
object Test {
7-
def test(): Unit = {
7+
def test1(): Unit = {
88
implicitly[B#X <:< A#X]
99
}
10+
def test2(): Unit = {
11+
val a : { type T; type U } = ???
12+
implicitly[a.T <:< a.U]
13+
}
1014
}

0 commit comments

Comments
 (0)