Skip to content

Commit c830ad2

Browse files
committed
Also consider bindings in classes when computing "refines"
1 parent 46e82dd commit c830ad2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -2503,17 +2503,17 @@ object Types {
25032503
* might depend on the given prefix.
25042504
* Note: If T is an abstract type in trait or class C, its info depends
25052505
* even on C.this if class C has a self type that refines the info of T.
2506-
* Currently, "refines" means an actual refinement type that constrains the
2507-
* name `T`. We should try to extend that also to other classes that introduce
2508-
* a new bining for `T`. Furthermore, we should also treat term members
2509-
* in this way.
2506+
* We should also treat term members in this way.
25102507
*/
25112508
private def infoDependsOnPrefix(symd: SymDenotation, prefix: Type)(using Context): Boolean =
25122509

25132510
def refines(tp: Type, name: Name): Boolean = tp match
25142511
case AndType(tp1, tp2) => refines(tp1, name) || refines(tp2, name)
25152512
case RefinedType(parent, rname, _) => rname == name || refines(parent, name)
2516-
case tp: RecType => refines(tp.parent, name)
2513+
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)
25172517
case _ => false
25182518

25192519
def givenSelfTypeOrCompleter(cls: Symbol) = cls.infoOrCompleter match

0 commit comments

Comments
 (0)