Skip to content

Commit c5ba1e9

Browse files
committed
Make checkNonCyclicInherited force less
According to its documentation, it should only be necessary when there's more than one parent, we can use this knowledge to exit early from the method. This avoids a cyclic reference involving a refinement type in t1957.scala which started happening after the completions-related changes in this PR.
1 parent e8a70f9 commit c5ba1e9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,14 @@ object Checking {
358358
}
359359

360360
/** Check type members inherited from different `parents` of `joint` type for cycles,
361-
* unless a type with the same name aleadry appears in `decls`.
361+
* unless a type with the same name already appears in `decls`.
362362
* @return true iff no cycles were detected
363363
*/
364364
def checkNonCyclicInherited(joint: Type, parents: List[Type], decls: Scope, posd: Positioned)(implicit ctx: Context): Unit = {
365+
// If we don't have more than one parent, then there's nothing to check
366+
if (parents.lengthCompare(1) <= 0)
367+
return
368+
365369
def qualifies(sym: Symbol) = sym.name.isTypeName && !sym.is(Private)
366370
val abstractTypeNames =
367371
for (parent <- parents; mbr <- parent.abstractTypeMembers if qualifies(mbr.symbol))

0 commit comments

Comments
 (0)