Minor, add test cases for obsolete protected-related issues
This commit is contained in:
@@ -5,11 +5,15 @@ public abstract class Test<F> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FILE: test.kt
|
// FILE: test.kt
|
||||||
|
// See KT-5445: Bad access to protected data in getfield
|
||||||
|
|
||||||
class A : Test<String>() {
|
class A : Test<String>() {
|
||||||
fun foo(): String? = value
|
fun foo(): String? = value
|
||||||
|
fun bar(): String? = this.value
|
||||||
}
|
}
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
return if (A().foo() == null) "OK" else "Fail"
|
if (A().foo() != null) return "Fail 1"
|
||||||
|
if (A().bar() != null) return "Fail 2"
|
||||||
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+31
@@ -0,0 +1,31 @@
|
|||||||
|
// FILE: test/Foo.java
|
||||||
|
|
||||||
|
package test;
|
||||||
|
|
||||||
|
public class Foo {
|
||||||
|
protected void foo(Runnable r) {
|
||||||
|
r.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
|
||||||
|
package other
|
||||||
|
|
||||||
|
import test.Foo
|
||||||
|
|
||||||
|
class Bar : Foo() {
|
||||||
|
fun bar() {
|
||||||
|
foo {}
|
||||||
|
foo(Runnable {})
|
||||||
|
// super.foo {}
|
||||||
|
super.foo(Runnable {})
|
||||||
|
this.foo {}
|
||||||
|
this.foo(Runnable {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
Bar().bar()
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+6
@@ -935,6 +935,12 @@ public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxAga
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedStaticClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedStaticClass.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("protectedSuperMethod.kt")
|
||||||
|
public void testProtectedSuperMethod() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedSuperMethod.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic")
|
@TestMetadata("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic")
|
||||||
|
|||||||
Reference in New Issue
Block a user