8000 Merge pull request #4397 from retronym/topic/icode-diagnostic · scala/scala@de4edd4 · GitHub
[go: up one dir, main page]

Skip to content

Commit de4edd4

Browse files
committed
Merge pull request #4397 from retronym/topic/icode-diagnostic
Improve diagnostic error on failed genLoadIdent
2 parents 2dc40cc + bdc0b63 commit de4edd4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/compiler/scala/tools/nsc/backend/icode/GenICode.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -876,13 +876,15 @@ abstract class GenICode extends SubComponent {
876876
genLoadModule(ctx, tree)
877877
generatedType = toTypeKind(sym.info)
878878
} else {
879-
try {
880-
val Some(l) = ctx.method.lookupLocal(sym)
881-
ctx.bb.emit(LOAD_LOCAL(l), tree.pos)
882-
generatedType = l.kind
883-
} catch {
884-
case ex: MatchError =>
885-
abort("symbol " + sym + " does not exist in " + ctx.method)
879+
ctx.method.lookupLocal(sym) match {
880+
case Some(l) =>
881+
ctx.bb.emit(LOAD_LOCAL(l), tree.pos)
882+
generatedType = l.kind
883+
case None =>
884+
val saved = settings.uniqid
885+
settings.uniqid.value = true
886+
try abort(s"symbol $sym does not exist in ${ctx.method}, which contains locals ${ctx.method.locals.mkString(",")}")
887+
finally settings.uniqid.value = saved
886888
}
887889
}
888890
}

0 commit comments

Comments
 (0)
0