@@ -2501,20 +2501,24 @@ object Types {
2501
2501
2502
2502
/** A reference with the initial symbol in `symd` has an info that
2503
2503
* might depend on the given prefix.
2504
- * Note: If T is an abstract type in trait or class C, its info depends
2505
- * even on C.this if class C has a self type that refines the info of T.
2506
- * We should also treat term members in this way .
2504
+ * Note: If M is an abstract type or non-final term member in trait or class C,
2505
+ * its info depends even on C.this if class C has a self type that refines
2506
+ * the info of M .
2507
2507
*/
2508
2508
private def infoDependsOnPrefix (symd : SymDenotation , prefix : Type )(using Context ): Boolean =
2509
2509
2510
2510
def refines (tp : Type , name : Name ): Boolean = tp match
2511
- case AndType (tp1, tp2) => refines(tp1, name) || refines(tp2, name)
2512
- case RefinedType (parent, rname, _) => rname == name || refines(parent, name)
2511
+ case AndType (tp1, tp2) =>
2512
+ refines(tp1, name) || refines(tp2, name)
2513
+ case RefinedType (parent, rname, _) =>
2514
+ rname == name || refines(parent, name)
2513
2515
case tp : ClassInfo =>
2514
- val other = tp.cls.infoOrCompleter.nonPrivateMember(name)
2515
- other.exists && other.symbol != symd.symbol
2516
- case tp : TypeProxy => refines(tp.underlying, name)
2517
- case _ => false
2516
+ val otherd = tp.cls.nonPrivateMembersNamed(name)
2517
+ otherd.exists && ! otherd.containsSym(symd.symbol)
2518
+ case tp : TypeProxy =>
2519
+ refines(tp.underlying, name)
2520
+ case _ =>
2521
+ false
2518
2522
2519
2523
def givenSelfTypeOrCompleter (cls : Symbol ) = cls.infoOrCompleter match
2520
2524
case cinfo : ClassInfo =>
@@ -2526,7 +2530,10 @@ object Types {
2526
2530
symd.maybeOwner.membersNeedAsSeenFrom(prefix) && ! symd.is(NonMember )
2527
2531
|| prefix.match
2528
2532
case prefix : Types .ThisType =>
2529
- symd.isAbstractType
2533
+ (symd.isAbstractType
2534
+ || symd.isTerm
2535
+ && ! symd.flagsUNSAFE.isOneOf(Module | Final | Param )
2536
+ && ! symd.maybeOwner.isEffectivelyFinal)
2530
2537
&& prefix.sameThis(symd.maybeOwner.thisType)
2531
2538
&& refines(givenSelfTypeOrCompleter(prefix.cls), symd.name)
2532
2539
case _ => false
0 commit comments