Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 16 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,22 @@ object TypeOps:
//
if (child.name == tpnme.LOCAL_CHILD) return child.typeRef

val childTp = if (child.isTerm) child.termRef else child.typeRef
val childTp = {
val parentSym = parent.typeSymbol
val parentPre = parent.normalizedPrefix
val defaultRef = if (child.isTerm) child.termRef else child.typeRef

if (parentSym.isClass && parentPre.isInstanceOf[TermRef]) {
val newPrefix = childPrefix(parentPre, parentSym, child)
if (newPrefix.exists)
if (child.isTerm) TermRef(newPrefix, child.asTerm)
else TypeRef(newPrefix, child.asType)
else
defaultRef
}
else
defaultRef
}

inContext(ctx.fresh.setExploreTyperState().setFreshGADTBounds.addMode(Mode.GadtConstraintInference)) {
instantiateToSubType(childTp, parent, mixins).dealias
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