File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -748,7 +748,22 @@ object TypeOps:
748
748
//
749
749
if (child.name == tpnme.LOCAL_CHILD ) return child.typeRef
750
750
751
- val childTp = if (child.isTerm) child.termRef else child.typeRef
751
+ val childTp = {
752
+ val parentSym = parent.typeSymbol
753
+ val parentPre = parent.normalizedPrefix
754
+ val defaultRef = if (child.isTerm) child.termRef else child.typeRef
755
+
756
+ if (parentSym.isClass && parentPre.isInstanceOf [TermRef ]) {
757
+ val newPrefix = childPrefix(parentPre, parentSym, child)
758
+ if (newPrefix.exists)
759
+ if (child.isTerm) TermRef (newPrefix, child.asTerm)
760
+ else TypeRef (newPrefix, child.asType)
761
+ else
762
+ defaultRef
763
+ }
764
+ else
765
+ defaultRef
766
+ }
752
767
753
768
inContext(ctx.fresh.setExploreTyperState().setFreshGADTBounds.addMode(Mode .GadtConstraintInference )) {
754
769
instantiateToSubType(childTp, parent, mixins).dealias
Original file line number Diff line number Diff line change
1
+ class Module {
2
+ type BarTy
3
+ sealed trait Adt [A ]
4
+ case class Foo () extends Adt [String ]
5
+ case class Bar [A <: BarTy ](x : BarTy ) extends Adt [A ]
6
+ }
7
+
8
+ object Basic extends Module {
9
+ type BarTy = String
10
+ }
11
+
12
+ def test (a : Basic .Adt [String ]) = {
13
+ a match { // warn: match may not be exhaustive
14
+ case Basic .Foo () =>
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments