Skip to content

Commit 9942821

Browse files
committed
Avoid infinite recursion in infoDependsOnPrefix
1 parent 8d65f19 commit 9942821

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

+10-5
Original file line numberDiff line numberDiff line change
@@ -2508,15 +2508,20 @@ object Types {
25082508
private def infoDependsOnPrefix(symd: SymDenotation, prefix: Type)(using Context): Boolean =
25092509

25102510
def refines(tp: Type, name: Name): Boolean = tp match
2511-
case AndType(tp1, tp2) =>
2512-
refines(tp1, name) || refines(tp2, name)
2511+
case tp: TypeRef =>
2512+
tp.symbol match
2513+
case cls: ClassSymbol =>
2514+
val otherd = cls.nonPrivateMembersNamed(name)
2515+
otherd.exists && !otherd.containsSym(symd.symbol)
2516+
case tsym =>
2517+
refines(tsym.info.hiBound, name)
2518+
// avoid going through tp.denot, since that might call infoDependsOnPrefix again
25132519
case RefinedType(parent, rname, _) =>
25142520
rname == name || refines(parent, name)
2515-
case tp: ClassInfo =>
2516-
val otherd = tp.cls.nonPrivateMembersNamed(name)
2517-
otherd.exists && !otherd.containsSym(symd.symbol)
25182521
case tp: TypeProxy =>
25192522
refines(tp.underlying, name)
2523+
case AndType(tp1, tp2) =>
2524+
refines(tp1, name) || refines(tp2, name)
25202525
case _ =>
25212526
false
25222527

0 commit comments

Comments
 (0)