Skip to content

Commit ed10162

Browse files
committed
Harden implicit scope computation against CyclicReference errors.
1 parent 431b2b7 commit ed10162

File tree

4 files changed

+6
-33
lines changed

4 files changed

+6
-33
lines changed

src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ object Contexts {
170170
if (implicitsCache == null )
171171
implicitsCache = {
172172
val implicitRefs: List[TermRef] =
173-
if (isClassDefContext) owner.thisType.implicitMembers
173+
if (isClassDefContext)
174+
try owner.thisType.implicitMembers
175+
catch {
176+
case ex: CyclicReference => Nil
177+
}
174178
else if (isImportContext) importInfo.importedImplicits
175179
else if (isNonEmptyScopeContext) scope.implicitDecls
176180
else Nil

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2976,7 +2976,7 @@ object Types {
29762976
val ex = new CyclicReference(denot)
29772977
if (!(ctx.mode is typer.Mode.CheckCyclic)) {
29782978
cyclicErrors.println(ex.getMessage)
2979-
for (elem <- ex.getStackTrace take 40)
2979+
for (elem <- ex.getStackTrace take 50)
29802980
cyclicErrors.println(elem.toString)
29812981
}
29822982
ex

tests/new/S5.scala

Lines changed: 0 additions & 31 deletions
This file was deleted.
File renamed without changes.

0 commit comments

Comments
 (0)