Skip to content

Commit 3357727

Browse files
committed
Fix #6460: less forcing in checkNonCyclic
checkNonCyclic was forcing too many infos because it didn't account for the case where the prefix is a ModuleVal and not a ModuleClass. Fixing this solves the incremental compilation issue in the Dotty build reported in #6460 were the root cause was a completion cycle when jointly compiling SymbolLoaders and Types that looked like this: Complete `object tpd` Complete its parent `Trees.Instance` Complete its type parameter `T >: Untyped <: Type` run `checkNonCyclic` on the the type parameter definition Complete `Type` Complete `import ast.tpd._` in `Types.scala` Eventually this requires unpickling the selection `Trees.Instance#T` which gets a `NoDenotation` since `T` hasn't been entered yet. As a side-effect this also means that the neg/toplevel-cyclic test no longer leads to an "illegal cyclic reference" error, instead it now causes "recursion limit exceeded" errors, which are less nice but still acceptable.
1 parent 637dc63 commit 3357727

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ object Checking {
240240
)
241241
case prefix: NamedType =>
242242
(!sym.is(Private) && prefix.derivesFrom(sym.owner)) ||
243-
(!prefix.symbol.isStaticOwner && isInteresting(prefix.prefix))
243+
(!prefix.symbol.moduleClass.isStaticOwner && isInteresting(prefix.prefix))
244244
case SuperType(thistp, _) => isInteresting(thistp)
245245
case AndType(tp1, tp2) => isInteresting(tp1) || isInteresting(tp2)
246246
case OrType(tp1, tp2) => isInteresting(tp1) && isInteresting(tp2)

compiler/test/dotty/tools/dotc/BootstrappedOnlyCompilationTests.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,15 @@ class BootstrappedOnlyCompilationTests extends ParallelTesting {
4848
compileDir("compiler/src/dotty/tools/dotc/reporting", withCompilerOptions),
4949
compileDir("compiler/src/dotty/tools/dotc/typer", withCompilerOptions),
5050
compileDir("compiler/src/dotty/tools/dotc/util", withCompilerOptions),
51-
compileDir("compiler/src/dotty/tools/io", withCompilerOptions)
51+
compileDir("compiler/src/dotty/tools/io", withCompilerOptions),
52+
compileList(
53+
"testIssue6460",
54+
List(
55+
"compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala",
56+
"compiler/src/dotty/tools/dotc/core/Types.scala"
57+
),
58+
withCompilerOptions
59+
),
5260
).checkCompile()
5361
}
5462

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
type A = B // error: illegal cyclic reference
1+
type A = B // error: recursion limit exceeded
22

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
type B = A
1+
type B = A // error: recursion limit exceeded // error: recursion limit exceeded

0 commit comments

Comments
 (0)