-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
scala/scala
#10823Description
Test example
Foo.java
public class Foo {
private String java;
public java.lang.Integer test() {
return null;
}
}Bar.scala
class Bar {
def main(): Unit = {
val bug = new Foo()
bug.test()
}
}compilation result:
[error] /Users/fdaca/git/scala-bug-test/src/main/java/Foo.java:4:17: value lang is not a member of String
[error] public java.lang.Integer test() {
[error] ^
Bug description
Given a mixed Java / Scala project with a Java class having both:
- a method declaration with a canonical name of return type (e.g.
public java.lang.Integer test()) - a field with name equal to the first package of declared method return type (e.g.
private String java)
Scala compiler would conflict the field identifier with package name and yield an error trying to lookup a member as if the first package was the previously declared field: value lang is not a member of String.
The same problem occurs with different identifiers: private Foo org; + public org.apache.commons.lang.CharSet getSet() would try to lookup member apache in type Foo.
Affected versions
- 2.13.1
- 2.12.8
- 2.11.8
hrhino, SethTisue, marcin-sumologic, eprst and cddude229