From c0341d348f4d431a54280027f80c41378ec36408 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 6 Feb 2020 13:40:10 +0100 Subject: [PATCH] Fix #8219: Use translucent supertype to decide AnyKindedness --- compiler/src/dotty/tools/dotc/core/Types.scala | 2 +- tests/neg/i8219.scala | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i8219.scala diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 25eb512080a9..726810ea4b6b 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -275,7 +275,7 @@ object Types { @tailrec def loop(tp: Type): Boolean = tp match { case tp: TypeRef => val sym = tp.symbol - if (sym.isClass) sym == defn.AnyKindClass else loop(tp.superType) + if (sym.isClass) sym == defn.AnyKindClass else loop(tp.translucentSuperType) case tp: TypeProxy => loop(tp.underlying) case _ => diff --git a/tests/neg/i8219.scala b/tests/neg/i8219.scala new file mode 100644 index 000000000000..c204f5f997d7 --- /dev/null +++ b/tests/neg/i8219.scala @@ -0,0 +1,4 @@ +object O{ + opaque type T[X <: AnyKind] = X +} +def m(x: O.T[AnyKind]) = x // error \ No newline at end of file