Skip to content

Commit 8375113

Browse files
committed
Better error message when an outer path is not found.
1 parent 09e1d88 commit 8375113

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,12 @@ object ExplicitOuter {
314314
val outerAccessorCtx = ctx.withPhaseNoLater(ctx.lambdaLiftPhase) // lambdalift mangles local class names, which means we cannot reliably find outer acessors anymore
315315
ctx.log(i"outer to $toCls of $tree: ${tree.tpe}, looking for ${outerAccName(treeCls.asClass)(outerAccessorCtx)} in $treeCls")
316316
if (treeCls == toCls) tree
317-
else loop(tree.select(outerAccessor(treeCls.asClass)(outerAccessorCtx)).ensureApplied)
317+
else {
318+
val acc = outerAccessor(treeCls.asClass)(outerAccessorCtx)
319+
assert(acc.exists,
320+
i"failure to construct path from ${ctx.owner.ownersIterator.toList}%/% to `this` of ${toCls.showLocated};\n${treeCls.showLocated} does not have an outer accessor")
321+
loop(tree.select(acc).ensureApplied)
322+
}
318323
}
319324
ctx.log(i"computing outerpath to $toCls from ${ctx.outersIterator.map(_.owner).toList}")
320325
loop(This(ctx.owner.enclosingClass.asClass))

0 commit comments

Comments
 (0)