bclymer
03/08/2016, 9:58 PMopen class A {
var publicGetAndSet: String = ""
var publicGetPrivateSet: String = ""
private set
}
class B : A() {
init {
this.publicGetAndSet = "Yay"
this.publicGetPrivateSet = "Yay"
}
}
crashes with
java.lang.IllegalAccessError: Method 'void com.example.myapp.A.setPublicGetPrivateSet(java.lang.String)' is inaccessible to class 'com.example.myapp.B'It seems like that shouldn't compile, since the setter is private. While following code does fail to compile
open class A {
var publicGetAndSet: String = ""
var publicGetPrivateSet: String = ""
private set
}
class B {
init {
val a = A()
a.publicGetAndSet = "Yay"
a.publicGetPrivateSet = "Yay" // fails to compile on this line, as expected.
}
}
So for the same reasoning, I'd expect snippet 1 to fail to compile.