diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 73a64f2c1b8f..d47eb41395b5 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -3005,7 +3005,8 @@ object Types { abstract case class SuperType(thistpe: Type, supertpe: Type) extends CachedProxyType with SingletonType { override def underlying(using Context): Type = supertpe override def superType(using Context): Type = - thistpe.baseType(supertpe.typeSymbol) + if supertpe.typeSymbol.exists then thistpe.baseType(supertpe.typeSymbol) + else super.superType def derivedSuperType(thistpe: Type, supertpe: Type)(using Context): Type = if ((thistpe eq this.thistpe) && (supertpe eq this.supertpe)) this else SuperType(thistpe, supertpe) diff --git a/tests/run/i17555.scala b/tests/run/i17555.scala new file mode 100644 index 000000000000..323d252eac8a --- /dev/null +++ b/tests/run/i17555.scala @@ -0,0 +1,17 @@ +class Root { + override def toString() = "Root" +} +trait A extends Root with B { } +trait B { + override def toString() = "B" +} +case class C() extends A { + override def toString() = super.toString() +} +class D() extends A, Serializable { + override def toString() = super.toString() +} + +@main def Test = + println(C()) + println(D()) \ No newline at end of file