summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-04-18 23:38:15 +0200
committerJason Zaugg <jzaugg@gmail.com>2013-04-18 23:44:11 +0200
commit3e27fec3cf44bcc523fea6bac39ac9b99b438393 (patch)
tree8f766d06992528b613171bd1d52d2f3e9de38200 /src
parent4525e9223a2fb7c1ec3014073566b559e5839805 (diff)
downloadscala-3e27fec3cf44bcc523fea6bac39ac9b99b438393.tar.gz
scala-3e27fec3cf44bcc523fea6bac39ac9b99b438393.tar.bz2
scala-3e27fec3cf44bcc523fea6bac39ac9b99b438393.zip
SI-7388 Be more robust against cycles in error symbol creation.
`Symbol#toString` was triggering `CyclicReferenceError` (specifically, `accurateKindString` which calls `owner.primaryConstructor`.) The `toString` output is used when creating an error symbol to assign to the tree after an error (in this case, a non-existent access qualifier.) This commit catches the error, and falls back to just using the symbol's name.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 7161043dcf..7dd182e3ee 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -286,7 +286,11 @@ trait Infer extends Checkable {
// println("set error: "+tree);
// throw new Error()
// }
- def name = newTermName("<error: " + tree.symbol + ">")
+ def name = {
+ val sym = tree.symbol
+ val nameStr = try sym.toString catch { case _: CyclicReference => sym.nameString }
+ newTermName(s"<error: $nameStr>")
+ }
def errorClass = if (context.reportErrors) context.owner.newErrorClass(name.toTypeName) else stdErrorClass
def errorValue = if (context.reportErrors) context.owner.newErrorValue(name) else stdErrorValue
def errorSym = if (tree.isType) errorClass else errorValue