-
Notifications
You must be signed in to change notification settings - Fork 21
Nested Java interfaces not found in Scala and Java #1409
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-1409?orig=1 |
@odersky said: That's unfortunately not an easy one (I am not even sure there is a way to fix this). The problem is that in public interface OuterInterface {
public interface InnerInterface {
public void foo();
}
}
abstract class AbstractImpl extends _root_.java.lang.Object with OuterInterface {
import OuterInterface._
def create(): InnerInterface
} But that's both incomplete and possibly incorrect. It's incomplete because |
@milessabin said: The problem here is that it forces existing correct Java code to be modified before it can be used in a mixed Scala/Java project. |
@milessabin said: |
@milessabin said: |
@milessabin said: |
@SethTisue said: |
@paulp said: |
@SethTisue said: full compilation, with all sources passed to scalac, succeeds. but then incremental recompilation, with only some sources passed to scalac, fails: % cat I.java
interface I { enum E { E1 } ; }
% cat J.java
class J implements I { private E e = E.E1 ; }
% cat S.scala
class S extends J
% /usr/local/scala-2.9.0.RC1/bin/scalac I.java J.java S.scala
% javac I.java J.java
% rm J.class S.class
% /usr/local/scala-2.9.0.RC1/bin/scalac J.java S.scala
J.java:1: error: not found: type E
class J implements I { private E e = E.E1 ; }
^
one error found the problem goes away if E is fully qualified in J: % cat I.java
interface I { enum E { E1 } ; }
% cat J.java
class J implements I { private I.E e = I.E.E1 ; }
% cat S.scala
class S extends J
% /usr/local/scala-2.9.0.RC1/bin/scalac I.java J.java S.scala
% javac I.java J.java
% rm J.class S.class
% /usr/local/scala-2.9.0.RC1/bin/scalac J.java S.scala |
@SethTisue said: |
@lrytz said: lampmac3:sandbox luc$$ ls
total 24
-rw-r--r-- 1 luc staff 36 Apr 12 16:00 A.java
-rw-r--r-- 1 luc staff 25 Apr 12 16:13 B.java
-rw-r--r-- 1 luc staff 48 Apr 12 16:12 Test.scala
lampmac3:sandbox luc$$ cat A.java
interface A {
interface I { }
}
lampmac3:sandbox luc$$ cat B.java
class B implements A { }
lampmac3:sandbox luc$$ cat Test.scala
class Test extends B {
def foo(): I = null
}
lampmac3:sandbox luc$$ javac *.java
lampmac3:sandbox luc$$ ../target/pack/bin/scalac Test.scala
Test.scala:2: error: not found: type I
def foo(): I = null
^
one error found |
@paulp said:
Even if I define the java like this (public/public) package j;
public interface A {
public interface I { }
} ...why does scala see it as "protected type I = A.I" ? |
Sasha Kazachonak (kazachonak) said: You can look at simple code examples here: Depending on whether you compile scala+java sources together or separately compiler forces you to use either But "JavaClass[TypeParam]#JavaInnerClass" form doesn't work at all when there is an intermediate Java class inherited. |
Interface class and interface members are static, so they go in the companion. The currently improved message is available on selections; maybe it could be extended to some "symbol not found" but at least checking selections in
|
Compiling the following two .java files with javac succeeds as expected,
However, if the following .scala class is added,
and all three are compiled with scalac 2.7.2.RC2, the following unexpected errors are reported against both the Scala and the Java,
The only workaround is to add redundant qualifiers to both the Java and the Scala sources,
The text was updated successfully, but these errors were encountered: