Closed
Description
A private member of a Java class, whose source is jointly compiled by scalac, is considered importable. If the java file is precompiled with javac and included on the classpath of scalac, it is no longer importable.
(I raised this on scala-user, but didn't get a reply.)
E:\code\scratch\access>cat HasPrivateFoo.java
class HasPrivateFoo {
private Object foo = null;
}
E:\code\scratch\access>cat Import.scala
object Import {
def test(foo: Any, h: HasPrivateFoo) {
import h._
foo
}
}
E:\code\scratch\access>scalac -version
Scala compiler version 2.8.0.Beta1-prerelease -- Copyright 2002-2010, LAMP/EPFL
E:\code\scratch\access>javac HasPrivateFoo.java
E:\code\scratch\access>scalac -classpath . Import.scala
E:\code\scratch\access>scalac Import.scala HasPrivateFoo.java
Import.scala:4: error: reference to foo is ambiguous;
it is both defined in method test and imported subsequently by
import h._
foo
^
one error found
E:\code\scratch\access>scalac -version
Scala compiler version 2.8.0.Beta1-prerelease -- Copyright 2002-2010, LAMP/EPFL
E:\code\scratch\access>rm *class
E:\code\scratch\access>E:\tools\scala-2.8.0.r21113-b20100309020141\bin\scalac Import.scala HasPrivateFoo.java
Import.scala:4: error: reference to foo is ambiguous;
it is both defined in method test and imported subsequently by
import h._
foo
^
one error found
Metadata
Metadata
Assignees
Labels
No labels