-
Notifications
You must be signed in to change notification settings - Fork 21
scalac gets confused when mixing java and scala sources where the java-source contains a public static final variable with the same name as a static inner class #4549
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4549?orig=1
|
Andreas Joseph Krogh (andreak) said: |
@dragos said: public class Fisk {
public static class A {
public static void foo() {
System.out.println("foo");
}
public int bar = 10;
}
public static A A = new A();
public static void test() {
int x = Fisk.A.bar;
Fisk.A.foo();
}
} class Foo {
Fisk.A.bar
Fisk.A.foo()
} you get: {code} |
Andreas Joseph Krogh (andreak) said: public void stuff() {
Fisk.A a = new Fisk.A();
Fisk.A b = Fisk.A;
int i = Fisk.A.bar;
Fisk.A.foo();
b.foo();
i = b.bar;
} This strikes me as strange as Scala is supposed to be, at least to my knowledge, 100% compatible with JAVA, but surely isn't as we've demonstrated here. Is this something you Scala-guys will take a note of and plan to address, or will it end up on the infamous incompatibility-list? -- |
@adriaanm said: |
Konstantin Nikiforov (nikifor) said: |
Konstantin Nikiforov (nikifor) said: Steps to reproduce: download, unpack, sbt compile. The only source code file is conf/routres. Sbt will download deps, generate router source code into target/scala-2.11/src_managed/main and take a try to compile it. It will fail with: [info] Compiling 4 Scala sources and 2 Java sources to /target/scala-2.11/classes...
[error] conf/routes: routes is already defined as object routes
[error] conf/routes: routes is already defined as class routes
[error] conf/routes:6: ReverseAssets is already defined as class ReverseAssets
[error] GET /assets/*file controllers.Assets.at(path="/public", file)
[error] conf/routes:6: ReverseAssets is already defined as class ReverseAssets
[error] GET /assets/*file controllers.Assets.at(path="/public", file)
[error] conf/routes:6: ReverseAssets is already defined as class ReverseAssets
[error] GET /assets/*file controllers.Assets.at(path="/public", file)
[error] conf/routes: Routes is already defined as object Routes
[error] 6 errors found
[error] (compile:compile) Compilation failed target/scala-2.11/src_generated/main contains java-source (in controllers/ subdir) with final static variables and inner static classes. Scala files contain inner classes, but DO NOT calling java-variables and inner-classes directly. So, this usecase slightly differs from original issue description. scala 2.11.2 |
@adriaanm said: |
This is mixed not separate compilation. Same for 3.5.2. |
Take the class
When calling it from Scala:
The compiler fails compiling it:
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: