Skip to content

Issue finding Java classes defined in interfaces when compiling Scala code referencing them #10859

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
pmeheut opened this issue May 1, 2018 · 1 comment

Comments

@pmeheut
Copy link

pmeheut commented May 1, 2018

In our Java code, we define Java classes as default implementation in interfaces such as:
interface Foo {
class DefaultFoo implements Foo {
}
}
See the attached file for a simple example: unzip it and try to compile it with:
scalac Foo.java Bar.java Quux.scala

You should get an error:
[error] /Users/pascal/foo/src/main/java/Bar.java:2:34: not found: type DefaultFoo [error] public class DefaultBar extends DefaultFoo implements Bar {

But javac (any version but we use 1.8 131) compiles this Java code.

We tried with Scala 2.11 (many versions) and Scala 2.12.5.

An obvious workaround is to change the java code to public class DefaultBar extends Foo.DefaultFoo
But as we have a huge code base written this way, this is inconvenient.
We also have the same bug inside methods where scala does not see enum defined as subclasses of an interface another Java class extends.

Foo.zip

@SethTisue
Copy link
Member

almost certainly a variant of #9111. you could add your reproducer as a comment there. @lrytz had intended to address it at scala/scala#5606 but it proved trickier than expected.

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

2 participants