mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
Class B : A cannot access a protected field of A through a reference to an instance of C : A.
22 lines
347 B
Kotlin
Vendored
22 lines
347 B
Kotlin
Vendored
// FILE: protectedPack/A.java
|
|
package protectedPack;
|
|
|
|
public class A {
|
|
protected final String field;
|
|
|
|
public A(String value) {
|
|
field = value;
|
|
}
|
|
}
|
|
|
|
// FILE: B.kt
|
|
import protectedPack.A
|
|
|
|
class B(value: String) : A(value) {
|
|
inner class C : A(field) {
|
|
val result = field
|
|
}
|
|
}
|
|
|
|
fun box(): String = B("OK").C().result
|