Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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.
  • Loading branch information...
commit 3e27fec3cf44bcc523fea6bac39ac9b99b438393 1 parent 4525e92
Jason Zaugg retronym authored
6 src/compiler/scala/tools/nsc/typechecker/Infer.scala
View
@@ -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
4 test/files/neg/t7388.check
View
@@ -0,0 +1,4 @@
+t7388.scala:1: error: doesnotexist is not an enclosing class
+class Test private[doesnotexist]()
+ ^
+one error found
1  test/files/neg/t7388.scala
View
@@ -0,0 +1 @@
+class Test private[doesnotexist]()
Please sign in to comment.
Something went wrong with that request. Please try again.