Skip to content

Commit f75dbdb

Browse files
committed
SI-5938 Test for a FSC bug with mixin, duplicate static forwarders
Under resident compilation, we were getting multiple copies of static forwarders created for mixed in methods. It seems like the bug was fixed as a by-product of scala#4040. This commit adds a test to show this. I've confirmed that the test fails appropriately with 2.11.4. For future reference, before I figured out how to write the test for this one (test/resident doesn't seem to let you run the code after compiling it), I was using bash to test as follows: (export V=2.11.x; (scalac-hash $V sandbox/t5938_1.scala; (for i in 1 2; do echo sandbox/t5938.scala; done; printf '\n') | scalac-hash $V -Xresident); stty echo; scala-hash $V X ; echo ':javap -public X' | scala-hash $V);
1 parent ced9e16 commit f75dbdb

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/files/run/t5938.scala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import scala.tools.partest.DirectTest
2+
3+
object Test extends DirectTest {
4+
5+
override def extraSettings: String =
6+
s"-usejavacp -d ${testOutput.path}"
7+
8+
override def code = """
9+
object O extends C {
10+
def main(args: Array[String]): Unit = {
11+
}
12+
// Static forwarder for foo and setter_foo_= added more once in a multi-run compile.
13+
}
14+
""".trim
15+
16+
override def show(): Unit = {
17+
val global = newCompiler()
18+
Console.withErr(System.out) {
19+
compileString(global)(code)
20+
compileString(global)(code)
21+
loadClass // was "duplicate name and signature in class X"
22+
}
23+
}
24+
25+
def loadClass: Class[_] = {
26+
val cl = new java.net.URLClassLoader(Array(testOutput.toFile.toURL));
27+
cl.loadClass("O")
28+
}
29+
}
30+
31+
trait T {
32+
val foo: String = ""
33+
}
34+
class C extends T
35+

0 commit comments

Comments
 (0)