Closed
Description
minimized code
Foo.scala:
trait Foo {
def f: String = ???
}
JavaFoo.java:
public abstract class JavaFoo {
public abstract int read();
}
iss1.scala:
class Bar extends JavaFoo with Foo {
def read(): Int = ???
}
@main def Test =
val stdout = new Bar
Compile the first two files with scalac and javac respectively:
javac JavaFoo.java; scalac Foo.scala
Then compile and run the third file with the *.class
files from the scalac and javac invocation on the classpath. From SBT:
;dotty-bootstrapped/dotc -classpath /path/to/classfiles/ /path/to/iss1.scala ;dotty-bootstrapped/dotr -classpath /path/to/classfiles/ Test
Runtime output
Exception in thread "main" java.lang.VerifyError: Bad operand type when invoking <init>
Exception Details:
Location:
Bar.<init>()V @5: invokespecial
Reason:
Invalid type: 'Bar' (current frame, stack[0])
Current Frame:
bci: @5
flags: { }
locals: { 'Bar' }
stack: { 'Bar' }
Bytecode:
0x0000000: 2ab7 000b 2ab7 000c b1
at iss1$package$.Test(iss1.scala:6)
at Test.main(iss1.scala:5)
If you debug with -Xprint, at some point Bar
has a bad constructor which calls super twice:
) class Bar extends JavaFoo, Foo {
def <init>(): Unit =
{
super()
super[Foo]()
()
}
expectation
Should run correctly.