summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-11-29 14:42:01 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-11-29 14:48:58 +1000
commit51d851ce2e403201d99d236a4bafd5728edc754f (patch)
tree749dd8e62ce2875bd4101d454676b68c3caff422 /test
parentb47aaf6445afe4a6818c31a0ed10e680e6b82c24 (diff)
downloadscala-51d851ce2e403201d99d236a4bafd5728edc754f.tar.gz
scala-51d851ce2e403201d99d236a4bafd5728edc754f.tar.bz2
scala-51d851ce2e403201d99d236a4bafd5728edc754f.zip
SD-275 Further harden against refs to absentee classes
- Limit the strategy of unpickling an external reference to a module class to a lookup of the module var to non-stub owners in order to enable fall through to stub symbol creation. Fixes scala/scala-dev#275
Diffstat (limited to 'test')
-rw-r--r--test/files/run/sd275-java/A.java5
-rw-r--r--test/files/run/sd275-java/DeleteMe.java4
-rw-r--r--test/files/run/sd275-java/LeaveMe.java3
-rw-r--r--test/files/run/sd275-java/Test.scala39
-rw-r--r--test/files/run/sd275.scala60
5 files changed, 111 insertions, 0 deletions
diff --git a/test/files/run/sd275-java/A.java b/test/files/run/sd275-java/A.java
new file mode 100644
index 0000000000..b293cf6dab
--- /dev/null
+++ b/test/files/run/sd275-java/A.java
@@ -0,0 +1,5 @@
+package sample;
+public class A {
+ public void irrelevant(p1.p2.p3.DeleteMe arg) {}
+ public static class A_Inner {}
+}
diff --git a/test/files/run/sd275-java/DeleteMe.java b/test/files/run/sd275-java/DeleteMe.java
new file mode 100644
index 0000000000..ccff2951d0
--- /dev/null
+++ b/test/files/run/sd275-java/DeleteMe.java
@@ -0,0 +1,4 @@
+package p1.p2.p3;
+
+public class DeleteMe {}
+
diff --git a/test/files/run/sd275-java/LeaveMe.java b/test/files/run/sd275-java/LeaveMe.java
new file mode 100644
index 0000000000..cb58f0080f
--- /dev/null
+++ b/test/files/run/sd275-java/LeaveMe.java
@@ -0,0 +1,3 @@
+package p1;
+
+public class LeaveMe {}
diff --git a/test/files/run/sd275-java/Test.scala b/test/files/run/sd275-java/Test.scala
new file mode 100644
index 0000000000..84187527d2
--- /dev/null
+++ b/test/files/run/sd275-java/Test.scala
@@ -0,0 +1,39 @@
+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 show(): Unit = {
+ deletePackage("p1/p2/p3")
+ deletePackage("p1/p2")
+
+ compileCode("""
+package sample
+
+class Test {
+ final class Inner extends A.A_Inner {
+ def foo = 42
+ }
+
+ def test = new Inner().foo
+}
+ """)
+ assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n"))
+ }
+
+ def deletePackage(name: String) {
+ val directory = new File(testOutput.path, name)
+ for (f <- directory.listFiles()) {
+ assert(f.getName.endsWith(".class"))
+ assert(f.delete())
+ }
+ assert(directory.listFiles().isEmpty)
+ assert(directory.delete())
+ }
+}
diff --git a/test/files/run/sd275.scala b/test/files/run/sd275.scala
new file mode 100644
index 0000000000..8cdee3ae15
--- /dev/null
+++ b/test/files/run/sd275.scala
@@ -0,0 +1,60 @@
+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 show(): Unit = {
+ compileCode("""
+package sample {
+
+ class A1 {
+ def irrelevant: p1.p2.p3.DeleteMe = null
+ }
+ object A1 {
+ class A1_Inner
+ }
+}
+
+package p1 {
+ class LeaveMe
+ package p2 {
+ package p3 {
+ class DeleteMe
+ }
+ }
+}
+ """)
+ assert(filteredInfos.isEmpty, filteredInfos)
+ deletePackage("p1/p2/p3")
+ deletePackage("p1/p2")
+
+ compileCode("""
+package sample
+
+class Test {
+ final class Inner extends A1.A1_Inner {
+ def foo = 42
+ }
+
+ def test = new Inner().foo
+}
+ """)
+ assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n")) // Included a MissingRequirementError before.
+ }
+
+ def deletePackage(name: String) {
+ val directory = new File(testOutput.path, name)
+ for (f <- directory.listFiles()) {
+ assert(f.getName.endsWith(".class"))
+ assert(f.delete())
+ }
+ assert(directory.listFiles().isEmpty)
+ assert(directory.delete())
+ }
+}