diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 6 | ||||
-rw-r--r-- | test/files/neg/t7388.check | 4 | ||||
-rw-r--r-- | test/files/neg/t7388.scala | 1 |
3 files changed, 10 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 diff --git a/test/files/neg/t7388.check b/test/files/neg/t7388.check new file mode 100644 index 0000000000..0a29e04896 --- /dev/null +++ b/test/files/neg/t7388.check @@ -0,0 +1,4 @@ +t7388.scala:1: error: doesnotexist is not an enclosing class +class Test private[doesnotexist]() + ^ +one error found diff --git a/test/files/neg/t7388.scala b/test/files/neg/t7388.scala new file mode 100644 index 0000000000..9ce9ea11b3 --- /dev/null +++ b/test/files/neg/t7388.scala @@ -0,0 +1 @@ +class Test private[doesnotexist]() |