Skip to content

Commit 37ec8dd

Browse files
committed
Don't recurse without bound in outerPath.
outerSelect returns EmptyTree if it hits a Symbol with no outer accessor. outerPath doesn't check for this and will happily hand the returned EmptyTree back to outerSelect, and so on until stack overflow. The fix is to check for an EmptyTree result and terminate. Fixes scala#10035.
1 parent c283e61 commit 37ec8dd

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,11 @@ abstract class ExplicitOuter extends InfoTransform
264264
protected def outerPath(base: Tree, from: Symbol, to: Symbol): Tree = {
265265
//Console.println("outerPath from "+from+" to "+to+" at "+base+":"+base.tpe)
266266
if (from == to) base
267-
else outerPath(outerSelect(base), from.outerClass, to)
267+
else {
268+
val outerSel = outerSelect(base)
269+
if (outerSel.isEmpty) EmptyTree
270+
else outerPath(outerSel, from.outerClass, to)
271+
}
268272
}
269273

270274

test/files/pos/t10035.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
trait Inner {
2+
def f(): Outer
3+
}
4+
5+
class Outer(o: Set[Inner]) {
6+
def this() = this(Set(1).map{
7+
case k => new Inner {
8+
def f(): Outer = Outer.this
9+
}
10+
})
11+
}

0 commit comments

Comments
 (0)