-
Notifications
You must be signed in to change notification settings - Fork 21
when mixing Scala and Java, scalac doesn't recognize unqualified name of inherited enum #1211
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-1211?orig=1 |
@SethTisue said: |
@paulp said: |
John Sirois (jsirois) said: $ scalac -version
Scala compiler version 2.9.2 -- Copyright 2002-2011, LAMP/EPFL
$ cat I.java
abstract class I { public enum E { E1 } }
$ cat J.java
class J extends I {
public void foo(E e) { }
}
$ cat S.scala
object S { (new J).foo(null) }
$ scalac I.java J.java S.scala
J.java:2: error: not found: type E
public void foo(E e) { }
^
one error found
The only changes from the initial bug example are s/interface/abstract class/ in I.java and scalac 2.9.2. Things test fine when I is an interface. I have not checked the scalac 2.8 variable. |
John Sirois (jsirois) said: $ cat I.java
abstract class I { public enum E { E1 } }
$ cat J.java
class J extends I {
public void foo(E e) { }
}
$ cat S.scala
object S { (new J).foo(null) }
$ ./bin/scalac -version
Scala compiler version 2.10.1 -- Copyright 2002-2013, LAMP/EPFL
$ ./bin/scalac I.java J.java S.scala
J.java:2: error: not found: type E
public void foo(E e) { }
^
one error found |
John Sirois (jsirois) said: $ /opt/scala-2.8.0.final/bin/scalac -version
Scala compiler version 2.8.0.final -- Copyright 2002-2010, LAMP/EPFL
$ /opt/scala-2.8.0.final/bin/scalac I.java J.java S.scala
J.java:2: error: not found: type E
public void foo(E e) { }
^
one error found $ /opt/scala-2.8.2.final/bin/scalac -version
Scala compiler version 2.8.2.final -- Copyright 2002-2010, LAMP/EPFL
$ /opt/scala-2.8.2.final/bin/scalac I.java J.java S.scala
J.java:2: error: not found: type E
public void foo(E e) { }
^
one error found |
John Sirois (jsirois) said (edited on Apr 21, 2013 11:54:58 PM UTC): Interface: [[syntax trees at end of parser]] // I.java
package <empty> {
private[<empty>] object I extends {
def <init>() = _;
object E extends {
def <init>() = _;
<stable> <static> val E1: E = _;
<static> def values(): scala.Array[E] = _;
<static> def valueOf(x: String): E = _
};
<static> class E extends _root_.java.lang.Enum[E] {
import E._;
def <init>() = _
}
};
abstract private[<empty>] trait I extends _root_.java.lang.Object {
import I._;
def <init>() = _;
protected type E = I.E
}
} Abstract class: [[syntax trees at end of parser]] // I.java
package <empty> {
private[<empty>] object I extends {
def <init>() = _;
object E extends {
def <init>() = _;
<stable> <static> val E1: E = _;
<static> def values(): scala.Array[E] = _;
<static> def valueOf(x: String): E = _
};
<static> class E extends _root_.java.lang.Enum[E] {
import E._;
def <init>() = _
}
};
abstract private[<empty>] class I extends _root_.java.lang.Object {
import I._;
def <init>() = _
}
} |
John Sirois (jsirois) said:
[jsirois@gill ~/dev/3rdparty/scala] (master *) $ git diff
{code} |
@soc said: |
We have a nice warning when selecting an element that appears to be a non-inherited Java static member. It should warn if the element name pops up as a static in any of the interfaces selected from. It doesn't warn for random symbol not found, however. |
@som-snytt Thank you for fixing the bug I reported in 2008 (!!!) |
compilation fails if all source files are passed to scalac:
but succeeds if javac is run first:
the bug is very easy to work around by writing out the name more fully:
I'm running r15746.
The text was updated successfully, but these errors were encountered: