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
protected def this has general access #4128
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4128?orig=1 |
Aaron Novstrup (anovstrup) said: |
@paulp said: package bip {
class Foo() {
protected def this(name: String) = this()
}
class Foo2 protected (name: String) { }
protected class Foo3(name: String) { }
}
package bop {
import bip._
object P {
val foo = new Foo("abc")
val foo2 = new Foo2("abc")
val foo3 = new Foo3("abc")
}
} In 2.7.7, that's three errors. bip.scala:15: error: wrong number of arguments for constructor Foo: ()bip.Foo
val foo = new Foo("abc")
^
bip.scala:16: error: constructor Foo2 cannot be accessed in object P
val foo2 = new Foo2("abc")
^
bip.scala:17: error: class Foo3 cannot be accessed in package bip
val foo3 = new Foo3("abc")
^
three errors found In 2.8.0 and 2.8.1, one error. bip.scala:17: error: class Foo3 cannot be accessed in package bip
val foo3 = new Foo3("abc")
^
one error found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
protected secondary constructors have general code access.
=== What is the expected behavior? ===
Protected def this should not be accessible by general code.
The compiler ought to flag an error.
=== What do you see instead? ===
Punt
=== Additional information ===
(for instance, a link to a relevant mailing list discussion)
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: