Skip to content

Commit fc3ba61

Browse files
committed
Fix cyclic reference in Trees.scala
The previous commit added _root_.scala.Serializable as a parent to every object, this lead to a cyclic reference manifesting itselfs as "not found: type Type" in Trees.scala that we worked around by replace `Type` with `Types.Type`. This commit fixes this properly by adding a shortcut in typedIdent when typing `_root_` which avoids forcing imports.
1 parent 33b9894 commit fc3ba61

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,7 @@ object Trees {
887887

888888
// ----- Generic Tree Instances, inherited from `tpt` and `untpd`.
889889

890-
// FIXME: Work around cyclic reference by writing `Types.Type` instead of `Type`
891-
abstract class Instance[T >: Untyped <: Types.Type] { inst =>
890+
abstract class Instance[T >: Untyped <: Type] { inst =>
892891

893892
type Tree = Trees.Tree[T]
894893
type TypTree = Trees.TypTree[T]

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ class Typer extends Namer
361361
if (untpd.isVarPattern(tree) && name.isTermName)
362362
return typed(desugar.patternVar(tree), pt)
363363
}
364+
// Shortcut for the root package, this is not just a performance
365+
// optimization, it also avoids forcing imports thus potentially avoiding
366+
// cyclic references.
367+
if (name == nme.ROOTPKG)
368+
return tree.withType(defn.RootPackage.termRef)
364369

365370
val rawType = {
366371
val saved1 = unimported

0 commit comments

Comments
 (0)