Skip to content

Commit 8c73426

Browse files
committed
Merge pull request #180 from smarter/fix/nosymbol-subtyping
Fix subtyping of types without symbols
2 parents 09d5673 + bec85a9 commit 8c73426

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ class TypeComparer(initctx: Context) extends DotClass {
450450
tp1 match {
451451
case tp1: NamedType =>
452452
val sym1 = tp1.symbol
453-
(if (sym1 eq tp2.symbol) (
453+
(if ((sym1 ne NoSymbol) && (sym1 eq tp2.symbol)) (
454454
ctx.erasedTypes
455455
|| sym1.isStaticOwner
456456
|| { // Implements: A # X <: B # X

test/dotc/tests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class tests extends CompilerTest {
9595
@Test def neg_t1843_variances = compileFile(negDir, "t1843-variances", xerrors = 1)
9696
@Test def neg_t2660_ambi = compileFile(negDir, "t2660", xerrors = 2)
9797
@Test def neg_t2994 = compileFile(negDir, "t2994", xerrors = 2)
98-
@Test def neg_subtyping = compileFile(negDir, "subtyping", xerrors = 1)
98+
@Test def neg_subtyping = compileFile(negDir, "subtyping", xerrors = 2)
9999
@Test def neg_variances = compileFile(negDir, "variances", xerrors = 2)
100100
@Test def neg_badAuxConstr = compileFile(negDir, "badAuxConstr", xerrors = 2)
101101
@Test def neg_typetest = compileFile(negDir, "typetest", xerrors = 1)

tests/neg/subtyping.scala

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

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

0 commit comments

Comments
 (0)