Skip to content

Commit 68325f6

Browse files
oderskyKordyjan
authored andcommitted
Avoid cyclic references due to F-bounds
1 parent b6c2c48 commit 68325f6

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

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

+6-1
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,12 @@ object Denotations {
11201120
then this
11211121
else if symbol.isAllOf(ClassTypeParam) then
11221122
val arg = symbol.typeRef.argForParam(pre, widenAbstract = true)
1123-
if arg.exists then derivedSingleDenotation(symbol, symbol.info.bounds & arg.bounds, pre)
1123+
if arg.exists then
1124+
val newBounds =
1125+
if symbol.isCompleted && !symbol.info.containsLazyRefs
1126+
then symbol.info.bounds & arg.bounds
1127+
else arg.bounds
1128+
derivedSingleDenotation(symbol, newBounds, pre)
11241129
else derived(symbol.info)
11251130
else derived(symbol.info)
11261131
}

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

+8
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,14 @@ object Types {
442442
final def containsWildcardTypes(using Context) =
443443
existsPart(_.isInstanceOf[WildcardType], StopAt.Static, forceLazy = false)
444444

445+
/** Does this type contain LazyRef types? */
446+
final def containsLazyRefs(using Context) =
447+
val acc = new TypeAccumulator[Boolean]:
448+
def apply(x: Boolean, tp: Type): Boolean = tp match
449+
case _: LazyRef => true
450+
case _ => x || foldOver(x, tp)
451+
acc(false, this)
452+
445453
// ----- Higher-order combinators -----------------------------------
446454

447455
/** Returns true if there is a part of this type that satisfies predicate `p`.

0 commit comments

Comments
 (0)