mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Fix for KT-4250: IllegalAccessError when using protected java member from lambda function
#KT-4250 Fixed
This commit is contained in:
10
compiler/testData/codegen/boxWithJava/statics/protectedSamConstructor/JavaClass.java
vendored
Normal file
10
compiler/testData/codegen/boxWithJava/statics/protectedSamConstructor/JavaClass.java
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
public class JavaClass {
|
||||
|
||||
public String runZ(Z z) {
|
||||
return z.run("O", "K");
|
||||
}
|
||||
|
||||
protected interface Z {
|
||||
String run(String s1, String s2);
|
||||
}
|
||||
}
|
||||
12
compiler/testData/codegen/boxWithJava/statics/protectedSamConstructor/Kotlin.kt
vendored
Normal file
12
compiler/testData/codegen/boxWithJava/statics/protectedSamConstructor/Kotlin.kt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
package zzz
|
||||
|
||||
import JavaClass
|
||||
import JavaClass.Z
|
||||
|
||||
class A : JavaClass() {
|
||||
fun test() = runZ(JavaClass.Z {a, b -> a + b})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return A().test()
|
||||
}
|
||||
7
compiler/testData/codegen/boxWithJava/statics/protectedStatic/First.java
vendored
Normal file
7
compiler/testData/codegen/boxWithJava/statics/protectedStatic/First.java
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
public abstract class First {
|
||||
protected static String TEST = "OK";
|
||||
|
||||
protected static String test() {
|
||||
return TEST;
|
||||
}
|
||||
}
|
||||
23
compiler/testData/codegen/boxWithJava/statics/protectedStatic/First.kt
vendored
Normal file
23
compiler/testData/codegen/boxWithJava/statics/protectedStatic/First.kt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
package anotherPackage
|
||||
|
||||
import First
|
||||
|
||||
class Second : First() {
|
||||
val some = { First.TEST }
|
||||
fun foo() = { First.test() }
|
||||
|
||||
val some2 = { TEST }
|
||||
fun foo2() = { test() }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if (Second().some.invoke() != "OK") return "fail 1"
|
||||
|
||||
if (Second().foo().invoke() != "OK") return "fail 2"
|
||||
|
||||
if (Second().some2.invoke() != "OK") return "fail 3"
|
||||
|
||||
if (Second().foo2().invoke() != "OK") return "fail 4"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
22
compiler/testData/codegen/boxWithJava/statics/protectedStatic2/Base.java
vendored
Normal file
22
compiler/testData/codegen/boxWithJava/statics/protectedStatic2/Base.java
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
public class Base {
|
||||
|
||||
protected static String BASE_ONLY = "BASE";
|
||||
|
||||
protected static String baseOnly() {
|
||||
return BASE_ONLY;
|
||||
}
|
||||
|
||||
protected static String TEST = "BASE";
|
||||
|
||||
protected static String test() {
|
||||
return TEST;
|
||||
}
|
||||
|
||||
public static class Derived extends Base {
|
||||
protected static String TEST = "DERIVED";
|
||||
|
||||
protected static String test() {
|
||||
return TEST;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
compiler/testData/codegen/boxWithJava/statics/protectedStatic2/Kotlin.kt
vendored
Normal file
31
compiler/testData/codegen/boxWithJava/statics/protectedStatic2/Kotlin.kt
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
package anotherPackage
|
||||
|
||||
import Base.Derived
|
||||
import Base
|
||||
|
||||
class Kotlin : Base.Derived() {
|
||||
fun doTest(): String {
|
||||
|
||||
if ({ TEST }() != "DERIVED") return "fail 1"
|
||||
if ({ test() }() != "DERIVED") return "fail 2"
|
||||
|
||||
if ({ Derived.TEST }() != "DERIVED") return "fail 3"
|
||||
if ({ Derived.test() }() != "DERIVED") return "fail 4"
|
||||
|
||||
if ({ Base.TEST }() != "BASE") return "fail 5"
|
||||
if ({ Base.test() }() != "BASE") return "fail 6"
|
||||
|
||||
|
||||
if ({ Base.BASE_ONLY }() != "BASE") return "fail 7"
|
||||
if ({ Base.baseOnly() }() != "BASE") return "fail 8"
|
||||
|
||||
if ({ BASE_ONLY }() != "BASE") return "fail 9"
|
||||
if ({ baseOnly() }() != "BASE") return "fail 10"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return Kotlin().doTest()
|
||||
}
|
||||
Reference in New Issue
Block a user