Skip to content

Commit

Permalink
Backport "Fix superType of SuperType" to LTS (#18942)
Browse files Browse the repository at this point in the history
Backports #17574 to the LTS branch.

PR submitted by the release tooling.
  • Loading branch information
Kordyjan authored Nov 17, 2023
2 parents 7fbe032 + 548513d commit f2d5539
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3037,7 +3037,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)
Expand Down
17 changes: 17 additions & 0 deletions tests/run/i17555.scala
Original file line number Diff line number Diff line change
@@ -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 =
assert(C().toString == "B")
assert(D().toString == "B")

0 comments on commit f2d5539

Please sign in to comment.