diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 0737249221f5..99ec720c7900 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -460,7 +460,7 @@ class TypeComparer(initctx: Context) extends DotClass { tp1 match { case tp1: NamedType => val sym1 = tp1.symbol - (if (sym1 eq tp2.symbol) ( + (if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol)) ( ctx.erasedTypes || sym1.isStaticOwner || { // Implements: A # X <: B # X diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index c4b34e0e90b0..82a148c76b11 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -87,7 +87,7 @@ class tests extends CompilerTest { @Test def neg_t1843 = compileFile(negDir, "t1843", xerrors = 1) @Test def neg_t1843_variances = compileFile(negDir, "t1843-variances", xerrors = 1) @Test def neg_t2994 = compileFile(negDir, "t2994", xerrors = 2) - @Test def neg_subtyping = compileFile(negDir, "subtyping", xerrors = 1) + @Test def neg_subtyping = compileFile(negDir, "subtyping", xerrors = 2) @Test def neg_variances = compileFile(negDir, "variances", xerrors = 2) @Test def dotc = compileDir(dotcDir + "tools/dotc", twice) diff --git a/tests/neg/subtyping.scala b/tests/neg/subtyping.scala index d7f849ddc650..a4a5a3d19faa 100644 --- a/tests/neg/subtyping.scala +++ b/tests/neg/subtyping.scala @@ -4,10 +4,11 @@ class B { class A extends B object Test { - def foo(a: A#X): Unit = { - return; + def test1(): Unit = { + implicitly[B#X <:< A#X] } - def test(): Unit = { - foo(??? : B#X); + def test2(): Unit = { + val a : { type T; type U } = ??? + implicitly[a.T <:< a.U] } }