From 079296632d8ef5ecc40aafa83757231599c78783 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 13 Nov 2012 11:02:30 +0100 Subject: SI-6440 Address regressions around MissingRequirementError Go back to using globalError to report when a stub's info is referenced, and only throw the MissingRequirementError when compilation really must abort due to having a StubTermSymbol in a place where a StubClassSymbol would have been a better choice. This situation arises when an entire package is missing from the classpath, as was the case in the reported bug. Adds `StoreReporterDirectTest`, which buffers messages issued during compilation for more structured interrogation. Use this in two test for manifests -- these tests were using a crude means of grepping compiler console output to focus on the relevant output, but this approach was insufficient with the new multi-line error message emitted as part of this change. Also used that base test class to add two new tests: one for the reported error (package missing), and another for a simpler error (class missing). The latter test shows how stub symbols allow code to compile if it doesn't the subset of signatures in some type that refer to a missing class. Gave the INFO/WARNING/ERROR members of Reporter sensible toString implementations; they inherit from Enumeration#Value in an unusual manner (why?) that means the built in toString of Enumeration printed `Severity@0`. --- test/files/run/t6440b.scala | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 test/files/run/t6440b.scala (limited to 'test/files/run/t6440b.scala') diff --git a/test/files/run/t6440b.scala b/test/files/run/t6440b.scala new file mode 100644 index 0000000000..974aca2844 --- /dev/null +++ b/test/files/run/t6440b.scala @@ -0,0 +1,61 @@ +import scala.tools.partest._ +import java.io.File + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def library1 = """ + package pack1 + trait T + class U { + def t = new T {} + def one = 1 + } + """ + + def library2 = """ + package pack2 + object V { + def u = new pack1.U + } + """ + + def app1 = """ + package pack3 + object Test { + pack2.V.u.one // okay + } + """ + + def app2 = """ + package pack3 + object Test { + pack2.V.u.t // we have to fail if T.class is misisng + } + """ + + def show(): Unit = { + compileCode(library1) + val pack1 = new File(testOutput.path, "pack1") + val tClass = new File(pack1, "T.class") + assert(tClass.exists) + assert(tClass.delete()) + + // allowed to compile, no direct reference to `T` + compileCode(library2) + assert(filteredInfos.isEmpty, filteredInfos) + + // allowed to compile, no direct reference to `T` + compileCode(app1) + assert(filteredInfos.isEmpty, filteredInfos) + + // bad symbolic reference error expected (but no stack trace!) + compileCode(app2) + println(filteredInfos.mkString("\n")) + } +} -- cgit v1.2.3