File tree 5 files changed +30
-5
lines changed
compiler/src/dotty/tools/dotc
5 files changed +30
-5
lines changed Original file line number Diff line number Diff line change @@ -311,8 +311,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
311
311
thirdTryNamed(tp2)
312
312
else
313
313
( (tp1.name eq tp2.name)
314
- && tp1.isMemberRef
315
- && tp2.isMemberRef
314
+ && tp2.isPrefixDependentMemberRef
316
315
&& isSubPrefix(tp1.prefix, tp2.prefix)
317
316
&& tp1.signature == tp2.signature
318
317
&& ! (sym1.isClass && sym2.isClass) // class types don't subtype each other
Original file line number Diff line number Diff line change @@ -2496,8 +2496,10 @@ object Types {
2496
2496
symd.maybeOwner.membersNeedAsSeenFrom(prefix) && ! symd.is(NonMember )
2497
2497
|| prefix.isInstanceOf [Types .ThisType ] && symd.is(Opaque ) // see pos/i11277.scala for a test where this matters
2498
2498
2499
- /** Is this a reference to a class or object member? */
2500
- def isMemberRef (using Context ): Boolean = designator match {
2499
+ /** Is this a reference to a class or object member with an info that might depend
2500
+ * on the prefix?
2501
+ */
2502
+ def isPrefixDependentMemberRef (using Context ): Boolean = designator match {
2501
2503
case sym : Symbol => infoDependsOnPrefix(sym, prefix)
2502
2504
case _ => true
2503
2505
}
Original file line number Diff line number Diff line change @@ -385,7 +385,7 @@ class TreeChecker extends Phase with SymTransformer {
385
385
386
386
val sym = tree.symbol
387
387
val symIsFixed = tpe match {
388
- case tpe : TermRef => ctx.erasedTypes || ! tpe.isMemberRef
388
+ case tpe : TermRef => ctx.erasedTypes || ! tpe.isPrefixDependentMemberRef
389
389
case _ => false
390
390
}
391
391
if (sym.exists && ! sym.is(Private ) &&
Original file line number Diff line number Diff line change
1
+ sealed trait TP :
2
+ type C
3
+ type P
4
+
5
+ final class Foo extends TP :
6
+ class C
7
+ enum P :
8
+ case A , B
9
+
10
+ object Bar extends TP :
11
+ class C
12
+ enum P :
13
+ case A , B , C
14
+
15
+ // Works
16
+ def test =
17
+ summon[Foo # P <:< TP # P ]
18
+ val a : TP # P = Foo ().P .A
19
+
20
+ // These fail
21
+ val b : TP # P = Bar .P .A : Bar .P
22
+ summon[Bar .type # P <:< TP # P ]
23
+ summon[Bar .P <:< TP # P ]
24
+ val c : TP # C = ??? : Bar .C
File renamed without changes.
You can’t perform that action at this time.
0 commit comments