blob: a75cb6c9eb63f631a057464267420a1eefdab3cd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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)
}
}
|