File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -830,9 +830,13 @@ object TypeOps:
830
830
prefixTVar.uncheckedNN
831
831
case ThisType (tref) if ! tref.symbol.isStaticOwner =>
832
832
val symbol = tref.symbol
833
+ val compatibleSingleton = singletons.valuesIterator.find(_.underlying.derivesFrom(symbol))
833
834
if singletons.contains(symbol) then
834
835
prefixTVar = singletons(symbol) // e.g. tests/pos/i16785.scala, keep Outer.this
835
836
prefixTVar.uncheckedNN
837
+ else if compatibleSingleton.isDefined then
838
+ prefixTVar = compatibleSingleton.get
839
+ prefixTVar.uncheckedNN
836
840
else if symbol.is(Module ) then
837
841
TermRef (this (tref.prefix), symbol.sourceModule)
838
842
else if (prefixTVar != null )
@@ -930,10 +934,11 @@ object TypeOps:
930
934
}
931
935
932
936
val inferThisMap = new InferPrefixMap
933
- val tvars = tp1.etaExpand match
937
+ val prefixInferredTp = inferThisMap(tp1)
938
+ val tvars = prefixInferredTp.etaExpand match
934
939
case eta : TypeLambda => constrained(eta)
935
940
case _ => Nil
936
- val protoTp1 = inferThisMap.apply(tp1) .appliedTo(tvars)
941
+ val protoTp1 = prefixInferredTp .appliedTo(tvars)
937
942
938
943
if gadtSyms.nonEmpty then
939
944
ctx.gadtState.addToConstraint(gadtSyms)
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
+ }
17
+
18
+ object Basic2 extends Module {
19
+ type BarTy = Int
20
+ }
21
+
22
+ def test2 (a : Basic2 .Adt [String ]) = {
23
+ a match {
24
+ case Basic2 .Foo () =>
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments