Skip to content
Open
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
9 changes: 7 additions & 2 deletions compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,13 @@ object TypeOps:
prefixTVar.uncheckedNN
case ThisType(tref) if !tref.symbol.isStaticOwner =>
val symbol = tref.symbol
val compatibleSingleton = singletons.valuesIterator.find(_.underlying.derivesFrom(symbol))
if singletons.contains(symbol) then
prefixTVar = singletons(symbol) // e.g. tests/pos/i16785.scala, keep Outer.this
prefixTVar.uncheckedNN
else if compatibleSingleton.isDefined then
prefixTVar = compatibleSingleton.get
prefixTVar.uncheckedNN
else if symbol.is(Module) then
TermRef(this(tref.prefix), symbol.sourceModule)
else if (prefixTVar != null)
Expand Down Expand Up @@ -905,10 +909,11 @@ object TypeOps:
}

val inferThisMap = new InferPrefixMap
val tvars = tp1.etaExpand match
val prefixInferredTp = inferThisMap(tp1)
val tvars = prefixInferredTp.etaExpand match
case eta: TypeLambda => constrained(eta)
case _ => Nil
val protoTp1 = inferThisMap.apply(tp1).appliedTo(tvars)
val protoTp1 = prefixInferredTp.appliedTo(tvars)

if gadtSyms.nonEmpty then
ctx.gadtState.addToConstraint(gadtSyms)
Expand Down
16 changes: 16 additions & 0 deletions tests/warn/i23369.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Module {
type BarTy
sealed trait Adt[A]
case class Foo() extends Adt[String]
case class Bar[A <: BarTy](x: BarTy) extends Adt[A]
}

object Basic extends Module {
type BarTy = String
}

def test(a: Basic.Adt[String]) = {
a match { // warn: match may not be exhaustive
case Basic.Foo() =>
}
}
Loading