Skip to content

Commit 9d6c104

Browse files
committed
Cyclicity checking independent of positions.
More robust cyclicity check which does not depend on source positions.
1 parent 05d286b commit 9d6c104

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,13 @@ object Checking {
168168
def forwardRef(tree: Tree) = flag("forward", tree)
169169
def selfRef(tree: Tree) = flag("self", tree)
170170
val checkTree = new TreeAccumulator[Unit] {
171+
private var seen = Set[Symbol]()
171172
def checkRef(tree: Tree, sym: Symbol) =
172-
if (sym.maybeOwner == refineCls && tree.pos.start <= sym.pos.end) forwardRef(tree)
173+
if (sym.maybeOwner == refineCls && !seen(sym)) forwardRef(tree)
173174
def apply(x: Unit, tree: Tree) = tree match {
175+
case tree: MemberDef =>
176+
foldOver(x, tree)
177+
seen += tree.symbol
174178
case tree @ Select(This(_), _) =>
175179
checkRef(tree, tree.symbol)
176180
case tree: RefTree =>

0 commit comments

Comments
 (0)