Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/init/Semantic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,20 @@ object Semantic:
ref match
case Select(supert: Super, _) =>
val SuperType(thisTp, superTp) = supert.tpe: @unchecked
val thisValue2 = extendTrace(ref) { resolveThis(thisTp.classSymbol.asClass, thisV, klass) }
val thisValue2 = extendTrace(ref) {
thisTp match
case thisTp: ThisType =>
cases(thisTp, thisV, klass)

case AndType(thisTp: ThisType, _) =>
// Self-type annotation will generate an intersection type for `this`.
// See examples/i17997.scala
cases(thisTp, thisV, klass)

case _ =>
report.warning("[Internal error] Unexpected type " + thisTp.show + ", trace:\n" + Trace.show, ref)
Hot
}
withTrace(trace2) { thisValue2.call(ref.symbol, args, thisTp, superTp) }

case Select(qual, _) =>
Expand Down
20 changes: 20 additions & 0 deletions tests/init/pos/i17997.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
abstract class FunSuite:
def foo(): Unit = println("FunSuite")

foo()

trait MySelfType

trait MyTrait extends FunSuite { this: MySelfType =>
}

abstract class MyAbstractClass extends FunSuite { this: MySelfType =>

override def foo() = {
println("MyAbstractClass")
super.foo()
}
}

final class MyFinalClass extends MyAbstractClass with MyTrait with MySelfType:
val n: Int = 100