summaryrefslogtreecommitdiff
path: root/test/files/run/t7741a/Test.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2015-04-09 19:37:43 +0300
committerLukas Rytz <lukas.rytz@typesafe.com>2015-04-09 19:37:43 +0300
commit68e05701cd9ef633f7a22b82794c81f67d45be16 (patch)
tree428fbdb725e0236f305b041bed73b185e407918e /test/files/run/t7741a/Test.scala
parent9b009b42a5631a3bece0b37ea244de8e2c4c9f0c (diff)
parentbbd693ae44bab4be2be7930641f8ca2bf27c962c (diff)
downloadscala-68e05701cd9ef633f7a22b82794c81f67d45be16.tar.gz
scala-68e05701cd9ef633f7a22b82794c81f67d45be16.tar.bz2
scala-68e05701cd9ef633f7a22b82794c81f67d45be16.zip
Merge pull request #4386 from retronym/ticket/7741
SI-7741: Be more tolerant of absent inner classfiles and non-Scala interface members
Diffstat (limited to 'test/files/run/t7741a/Test.scala')
-rw-r--r--test/files/run/t7741a/Test.scala47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/files/run/t7741a/Test.scala b/test/files/run/t7741a/Test.scala
new file mode 100644
index 0000000000..a75cb6c9eb
--- /dev/null
+++ b/test/files/run/t7741a/Test.scala
@@ -0,0 +1,47 @@
+import java.io.{ByteArrayInputStream, FileOutputStream, BufferedOutputStream}
+import java.util
+
+import java.io.File
+
+import scala.tools.partest.DirectTest
+
+object Test extends DirectTest {
+
+ def code = ""
+
+ override def show(): Unit = {
+
+ val class1: Array[Byte] = GroovyInterfaceDump.dump()
+ val class2: Array[Byte] = GroovyInterface$1Dump.dump()
+ def writeFile(contents: Array[Byte], f: java.io.File): Unit = {
+ val out = new BufferedOutputStream(new FileOutputStream(f))
+ try {
+ out.write(contents)
+ } finally out.close()
+ }
+
+ val outdir = testOutput.jfile
+
+ // interface GroovyInterface {
+ //
+ // // This is the line that causes scalac to choke.
+ // // It results in a GroovyInterface$1 class, which is a non-static inner class but it's constructor does not
+ // // include the implicit parameter that is the immediate enclosing instance.
+ // // See http://jira.codehaus.org/browse/GROOVY-7312
+ // //
+ // // Scalac error:
+ // // [scalac] error: error while loading 1, class file '..../scala_groovy_interop/classes/com/example/groovy/GroovyInterface$1.class' is broken
+ // // [scalac] (class java.util.NoSuchElementException/head of empty list)
+ // final static def closure = { x -> "banana" }
+ //
+ // }
+ writeFile(GroovyInterfaceDump.dump(), new File(outdir, "GroovyInterface.class"))
+ writeFile(GroovyInterface$1Dump.dump(), new File(outdir, "GroovyInterface$1.class"))
+ compileCode("object Test { def foo(g: GroovyInterface) = g.toString }")
+ }
+
+ 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)
+ }
+}