Skip to content

Private member of jointly compiled java class is importable. #3160

Closed
@scabug

Description

@scabug

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions