summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2011-11-14 16:28:45 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2011-11-14 16:28:45 +0000
commitdc3fdb0d493a7aa8b5a8905b92248275471b7b74 (patch)
tree5749125c411e0a89dc7ff6d27318a29690ae48c8
parent76e35fa14104cc517f7ef7697507015bee7e0a89 (diff)
downloadscala-dc3fdb0d493a7aa8b5a8905b92248275471b7b74.tar.gz
scala-dc3fdb0d493a7aa8b5a8905b92248275471b7b74.tar.bz2
scala-dc3fdb0d493a7aa8b5a8905b92248275471b7b74.zip
null-robustness for presentation test
ran into NPEs while running the test suite using the virtpatmat compiler, decided it might happen to others thus undertook to shield said others from sad NPEs no review
-rw-r--r--src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
index 0ca52dcba7..40bbd3fa8e 100644
--- a/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
+++ b/src/compiler/scala/tools/nsc/interactive/tests/core/CoreTestDefs.scala
@@ -81,7 +81,11 @@ private[tests] trait CoreTestDefs
else {
reporter.println("\naskHyperlinkPos for `" + tree.symbol.name + "` at " + format(pos) + " " + pos.source.file.name)
val r = new Response[Position]
- val sourceFile = sourceFiles.find(tree.symbol.sourceFile.path == _.path) match {
+ // `tree.symbol.sourceFile` was discovered to be null when testing -Yvirtpatmat on the akka presentation test, where a position had shifted to point to `Int`
+ // askHyperlinkPos for `Int` at (73,19) pi.scala --> class Int in package scala has null sourceFile!
+ val treePath = if (tree.symbol.sourceFile ne null) tree.symbol.sourceFile.path else null
+ val treeName = if (tree.symbol.sourceFile ne null) tree.symbol.sourceFile.name else null
+ val sourceFile = sourceFiles.find(_.path == treePath) match {
case Some(source) =>
compiler.askLinkPos(tree.symbol, source, r)
r.get match {
@@ -93,7 +97,7 @@ private[tests] trait CoreTestDefs
ex.printStackTrace()
}
case None =>
- reporter.println("[error] could not locate sourcefile `" + tree.symbol.sourceFile.name + "`." +
+ reporter.println("[error] could not locate sourcefile `" + treeName + "`." +
"Hint: Does the looked up definition come form a binary?")
}
}