-
Notifications
You must be signed in to change notification settings - Fork 21
Private member of jointly compiled java class is importable. #3160
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-3160?orig=1 |
@axel22 said: Thanks |
@milessabin said: |
@paulp said: Stephane's original example is not covered by the spec, which says that
all importable members are counted. A member is importable as long as
it is not private[this]. Why this wording? Because an inner class might
validly import the private members of its companion object. That would be a distressing outcome, and not just for this. It seems like we shouldn't have to pollute the namespace of everyone who imports a package with a bunch of inaccessible symbols, just to keep the door open for some hypothetical inner classes. Also, see previous ticket of mine #3836, "ambiguous references which aren't." But it's worse than I had realized at the time. You can't even use aliases in your own package, private to your own package, without ruining the package. package object foo {
private[foo] type InputStream = java.io.InputStream
// oddly there is no conflict if there's no qualifier,
// though the quote from martin would imply otherwise.
// private type InputStream = java.io.InputStream
}
object bar {
import foo._
import java.io._
var x: InputStream = null
}
// 9: error: reference to InputStream is ambiguous;
// it is imported twice in the same scope by
// import java.io._
// and import foo._
// var x: InputStream = null
// ^
// one error found I think this is terribly unfortunate. And should be treated as an In the wontfix for #3836 martin says he doesn't want name lookup to start intruding on symbol resolution and typing. That's fine. I see this as like implicit resolution or type inference, where there is often some ambiguity which would be resolved if the process continued. An implicit is ruled out because the type parameters don't match its bounds, etc. But the biggest thing is that private names which affect an unrelated class's namespace cannot really be called private. |
@Blaisorblade said (edited on Mar 12, 2012 12:51:58 AM UTC): |
@som-snytt should this ticket be closed? |
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.)
The text was updated successfully, but these errors were encountered: