Skip to content

self types+separate compilation+Yinline = method not found #4784

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scabug opened this issue Jul 10, 2011 · 5 comments
Closed

self types+separate compilation+Yinline = method not found #4784

scabug opened this issue Jul 10, 2011 · 5 comments

Comments

@scabug
Copy link

scabug commented Jul 10, 2011

File test1.scala:

trait Foo { this: Bar => def foo = 7 }
trait Bar extends Foo

File test2.scala:

object Test {
  def main(args: Array[String]) = {
    new Bar { }
  }
}

Compile and run:

$scalac test1.scala
$scalac test2.scala
$scala Test
java.lang.NoSuchMethodError: Foo$class.$init$(LFoo;)V
	at Test$$anon$1.<init>(test2.scala:3)
	at Test$.main(test2.scala:3)
	at Test.main(test2.scala)

Javap reveals that method Foo$class.$init$ is generated with parameter type Bar not Foo. Compiling both files together works fine.

@scabug
Copy link
Author

scabug commented Jul 10, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4784?orig=1
Reporter: @TiarkRompf
Assignee: @magarciaEPFL

@scabug
Copy link
Author

scabug commented Jul 10, 2011

@paulp said:
I can't reproduce this with 2.8, 2.9, or trunk. I get identical bytecode compiled separately or together. I tried some variations without eliciting a bug. And the call it correctly with a Bar.

5: invokestatic #21; //Method Foo$class.$init$:(LBar;)V

Can you see what might be missing or altered from the situation which achieved failure?

@scabug
Copy link
Author

scabug commented Jul 10, 2011

@TiarkRompf said (edited on Jul 10, 2011 5:40:37 PM UTC):
I checked again with the prebuilt nightly and indeed, no problem there. It turns out that in the build I used previously, I had disabled the check that prevents loading XX$class.class files (see #4767). Consequently, using the nightly, this one fails for scalac -Yinline (curiously enough not for -optimize ??).

@scabug
Copy link
Author

scabug commented Jul 12, 2011

@paulp said:
That's weird, I had of course tried -optimise figuring that's where the problem lay. It almost has to be a second bug that one fails and one doesn't, like (what comes to mind not having yet looked at it) the way -optimise enables -Yinline happens too late, after some other latch has flipped the wrong way.

@scabug
Copy link
Author

scabug commented Jul 11, 2012

@magarciaEPFL said:
Just tried with several combinations of -Yinline for test1.scala and test2.scala, as well as with and without -optimize, against 026a70d55591c3b5ee157e22998b62168afee686 . In all cases there was no java.lang.NoSuchMethodError.

@scabug scabug closed this as completed Jul 11, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant