-
Notifications
You must be signed in to change notification settings - Fork 21
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
qualified private allowed to escape via aliases #5008
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5008?orig=1 |
@paulp said: |
@lrytz said: |
@paulp said: |
@paulp said: Not only did I not find it, I can't find anything which unambiguously states what it even means to attach an access modifier to a type; there certainly is nothing about what happens under aliasing; and I'm dying to see the language which would allow one to discover the behavior demonstrated here. For nine possible modifiers ("public", private[pkg], private[class], private[this], private, protected[pkg], protected[class], protected[this], protected) there are a total of two distinct behaviors shown in this code. I await the elaboration of how the "nifty" difference alluded to but not given can explain the following. The two behavior groupings are: private and private[this] - these are prevented from escaping everywhere Here is a comment. The code I'll attach separately.
|
@paulp said: package foo {
class A {
trait Foo
protected trait FooProt1
protected[this] trait FooProt2
protected[foo] trait FooProt3
protected[A] trait FooProt4
private trait FooPriv1
private[this] trait FooPriv2
private[foo] trait FooPriv3
private[A] trait FooPriv4
type BarProt1 = FooProt1
type BarProt2 = FooProt2
type BarProt3 = FooProt3
type BarProt4 = FooProt4
// type BarPriv1 = FooPriv1
// type BarPriv2 = FooPriv2
type BarPriv3 = FooPriv3
type BarPriv4 = FooPriv4
def fprot1(x: FooProt1) = x
def fprot2(x: FooProt2) = x
def fprot3(x: FooProt3) = x
def fprot4(x: FooProt4) = x
// def fpriv1(x: FooPriv1) = x
// def fpriv2(x: FooPriv2) = x
def fpriv3(x: FooPriv3) = x
def fpriv4(x: FooPriv4) = x
val yprot1 = new FooProt1 { }
val yprot2 = new FooProt2 { }
val yprot3 = new FooProt3 { }
val yprot4 = new FooProt4 { }
// val ypriv1 = new FooPriv1 { }
// val ypriv2 = new FooPriv2 { }
val ypriv3 = new FooPriv3 { }
val ypriv4 = new FooPriv4 { }
def fpriv_alt1(x: FooPriv1) = 0 // !!! isn't the private type now in the signature of the (public) method?
def fpriv_alt2(x: FooPriv2) = 0 // !!! isn't the private[this] type now in the signature of the (public) method?
}
// Same package, subclass
class B extends A {
val xprot1 = new BarProt1 { }
val xprot2 = new BarProt2 { }
val xprot3 = new BarProt3 { }
val xprot4 = new BarProt4 { }
// val xpriv1 = new BarPriv1 { }
// val xpriv2 = new BarPriv2 { }
val xpriv3 = new BarPriv3 { }
val xpriv4 = new BarPriv4 { }
override def fprot1(x: BarProt1) = x
override def fprot2(x: BarProt2) = x
override def fprot3(x: BarProt3) = x
override def fprot4(x: BarProt4) = x
// override def fpriv1(x: BarPriv1) = x
// override def fpriv2(x: BarPriv2) = x
override def fpriv3(x: BarPriv3) = x
override def fpriv4(x: BarPriv4) = x
}
// Same package, unrelated class
class C {
val a = new A
import a._
val xprot1 = new BarProt1 { }
val xprot2 = new BarProt2 { }
val xprot3 = new BarProt3 { }
val xprot4 = new BarProt4 { }
// val xpriv1 = new BarPriv1 { }
// val xpriv2 = new BarPriv2 { }
val xpriv3 = new BarPriv3 { }
val xpriv4 = new BarPriv4 { }
}
}
package bar {
// Different package, subclass
class B extends foo.A {
val xprot1 = new BarProt1 { }
val xprot2 = new BarProt2 { }
val xprot3 = new BarProt3 { }
val xprot4 = new BarProt4 { }
// val xpriv1 = new BarPriv1 { }
// val xpriv2 = new BarPriv2 { }
val xpriv3 = new BarPriv3 { }
val xpriv4 = new BarPriv4 { }
override def fprot1(x: BarProt1) = x
override def fprot2(x: BarProt2) = x
override def fprot3(x: BarProt3) = x
override def fprot4(x: BarProt4) = x
// override def fpriv1(x: BarPriv1) = x
// override def fpriv2(x: BarPriv2) = x
override def fpriv3(x: BarPriv3) = x
override def fpriv4(x: BarPriv4) = x
}
// Different package, unrelated class
class C {
val a = new foo.A
import a._
val xprot1 = new BarProt1 { }
val xprot2 = new BarProt2 { }
val xprot3 = new BarProt3 { }
val xprot4 = new BarProt4 { }
// val xpriv1 = new BarPriv1 { }
// val xpriv2 = new BarPriv2 { }
val xpriv3 = new BarPriv3 { }
val xpriv4 = new BarPriv4 { }
}
} |
@paulp said: |
@paulp said: |
There are so many access related tickets open I can't tell in a reasonable amount of time if this already exists. Not so great.
The text was updated successfully, but these errors were encountered: