Support bridges in interfaces for default methods
This commit is contained in:
@@ -1460,7 +1460,8 @@ public class FunctionCodegen {
|
||||
iv.invokespecial(parentInternalName, delegateTo.getName(), delegateTo.getDescriptor(), false);
|
||||
}
|
||||
else {
|
||||
if (JvmAnnotationUtilKt.isCompiledToJvmDefaultIfNoAbstract(descriptor, state.getJvmDefaultMode())) {
|
||||
if (isInterface(descriptor.getContainingDeclaration()) &&
|
||||
JvmAnnotationUtilKt.isCompiledToJvmDefaultIfNoAbstract(descriptor, state.getJvmDefaultMode())) {
|
||||
iv.invokeinterface(v.getThisName(), delegateTo.getName(), delegateTo.getDescriptor());
|
||||
}
|
||||
else {
|
||||
|
||||
Generated
+60
@@ -14938,6 +14938,36 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInClass.kt")
|
||||
public void testBridgeInClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface.kt")
|
||||
public void testBridgeInInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface2.kt")
|
||||
public void testBridgeInInterface2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties.kt")
|
||||
public void testBridgeInInterfaceWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties2.kt")
|
||||
public void testBridgeInInterfaceWithProperties2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithJava.kt")
|
||||
public void testBridgeWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithProperties.kt")
|
||||
public void testBridgeWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties.kt");
|
||||
@@ -15137,6 +15167,36 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInClass.kt")
|
||||
public void testBridgeInClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface.kt")
|
||||
public void testBridgeInInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface2.kt")
|
||||
public void testBridgeInInterface2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties.kt")
|
||||
public void testBridgeInInterfaceWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties2.kt")
|
||||
public void testBridgeInInterfaceWithProperties2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithJava.kt")
|
||||
public void testBridgeWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithProperties.kt")
|
||||
public void testBridgeWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties.kt");
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface Test<T> {
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p + "K"
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
return t.test(p)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "O")
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface Test<T> {
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2: Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p + "K"
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2 {
|
||||
}
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
return t.test(p)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "O")
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
|
||||
interface Test<T> {
|
||||
fun test(p: T): T {
|
||||
return null!!
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2: Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun box(): String {
|
||||
checkMethodExists(Test2::class.java, "test", Any::class.java)
|
||||
checkMethodExists(Test2::class.java, "test", String::class.java)
|
||||
|
||||
checkNoMethod(TestClass::class.java, "test", String::class.java)
|
||||
checkNoMethod(TestClass::class.java, "test", Any::class.java)
|
||||
|
||||
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkMethodExists(test2DefaultImpls, "test", Test2::class.java, String::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "test", Test2::class.java, Any::class.java)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
|
||||
fun checkMethodExists(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
return
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
throw AssertionError("fail: method $name was not found in " + clazz, e)
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface Test<T> {
|
||||
var test: T
|
||||
get() = null!!
|
||||
set(value) {
|
||||
null!!
|
||||
}
|
||||
}
|
||||
var result = "fail"
|
||||
|
||||
interface Test2 : Test<String> {
|
||||
override var test: String
|
||||
get() = result
|
||||
set(value) {
|
||||
result = value
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
t.test = p
|
||||
return t.test
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "OK")
|
||||
}
|
||||
Vendored
+63
@@ -0,0 +1,63 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
|
||||
interface Test<T> {
|
||||
var T.test: T
|
||||
get() = null!!
|
||||
set(value) {
|
||||
null!!
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2 : Test<String> {
|
||||
override var String.test: String
|
||||
get() = ""
|
||||
set(value) {}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun box(): String {
|
||||
checkMethodExists(Test2::class.java, "getTest", String::class.java)
|
||||
checkMethodExists(Test2::class.java, "getTest", Any::class.java)
|
||||
checkMethodExists(Test2::class.java, "setTest", Any::class.java, Any::class.java)
|
||||
checkMethodExists(Test2::class.java, "setTest", String::class.java, String::class.java)
|
||||
|
||||
checkNoMethod(TestClass::class.java, "getTest", String::class.java)
|
||||
checkNoMethod(TestClass::class.java, "getTest", Any::class.java)
|
||||
checkNoMethod(TestClass::class.java, "setTest", Any::class.java, Any::class.java)
|
||||
checkNoMethod(TestClass::class.java, "setTest", String::class.java, String::class.java)
|
||||
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkMethodExists(test2DefaultImpls, "getTest", Test2::class.java, String::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "getTest", Test2::class.java, Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "setTest", Test2::class.java, Any::class.java, Any::class.java)
|
||||
checkMethodExists(test2DefaultImpls, "setTest", Test2::class.java, String::class.java, String::class.java)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
|
||||
fun checkMethodExists(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
return
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
throw AssertionError("fail: method $name was not found in " + clazz, e)
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
// !JVM_DEFAULT_MODE: all-compatibility
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: Test.java
|
||||
|
||||
public interface Test<T> {
|
||||
default T test(T p) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: kotlin.kt
|
||||
|
||||
interface Test2: Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p
|
||||
}
|
||||
|
||||
fun forDefaultImpls() {}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun box(): String {
|
||||
checkMethodExists(Test2::class.java, "test", String::class.java)
|
||||
checkMethodExists(Test2::class.java, "test", Any::class.java)
|
||||
|
||||
checkNoMethod(TestClass::class.java, "test", String::class.java)
|
||||
checkNoMethod(TestClass::class.java, "test", Any::class.java)
|
||||
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkNoMethod(test2DefaultImpls, "test", Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "test", String::class.java)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
|
||||
fun checkMethodExists(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
return
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
throw AssertionError("fail: method $name was not found in " + clazz, e)
|
||||
}
|
||||
|
||||
}
|
||||
+4
-4
@@ -52,10 +52,10 @@ fun box(): String {
|
||||
checkMethodExists(TestClass::class.java, "setFoo", String::class.java, String::class.java)
|
||||
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkNoMethod(test2DefaultImpls, "getTest", String::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "getTest", Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "setTest", Any::class.java, Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "setTest", String::class.java, String::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "getTest", Test2::class.java, String::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "getTest", Test2::class.java, Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "setTest", Test2::class.java, Any::class.java, Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "setTest", Test2::class.java, String::class.java, String::class.java)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface Test<T> {
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p + "K"
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
return t.test(p)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "O")
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface Test<T> {
|
||||
fun test(p: T): T {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2: Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p + "K"
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2 {
|
||||
}
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
return t.test(p)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "O")
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
|
||||
interface Test<T> {
|
||||
fun test(p: T): T {
|
||||
return null!!
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2: Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun box(): String {
|
||||
checkMethodExists(Test2::class.java, "test", Any::class.java)
|
||||
checkMethodExists(Test2::class.java, "test", String::class.java)
|
||||
|
||||
checkNoMethod(TestClass::class.java, "test", String::class.java)
|
||||
checkNoMethod(TestClass::class.java, "test", Any::class.java)
|
||||
|
||||
try {
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkNoMethod(test2DefaultImpls, "test", String::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "test", Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "test", Test2::class.java, Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "test", Test2::class.java, Any::class.java)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
//or no class
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
|
||||
fun checkMethodExists(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
return
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
throw AssertionError("fail: method $name was not found in " + clazz, e)
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
|
||||
interface Test<T> {
|
||||
var test: T
|
||||
get() = null!!
|
||||
set(value) {
|
||||
null!!
|
||||
}
|
||||
}
|
||||
var result = "fail"
|
||||
|
||||
interface Test2 : Test<String> {
|
||||
override var test: String
|
||||
get() = result
|
||||
set(value) {
|
||||
result = value
|
||||
}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun <T> execute(t: Test<T>, p: T): T {
|
||||
t.test = p
|
||||
return t.test
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return execute(TestClass(), "OK")
|
||||
}
|
||||
Vendored
+67
@@ -0,0 +1,67 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
|
||||
interface Test<T> {
|
||||
var T.test: T
|
||||
get() = null!!
|
||||
set(value) {
|
||||
null!!
|
||||
}
|
||||
}
|
||||
|
||||
interface Test2 : Test<String> {
|
||||
override var String.test: String
|
||||
get() = ""
|
||||
set(value) {}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun box(): String {
|
||||
checkMethodExists(Test2::class.java, "getTest", String::class.java)
|
||||
checkMethodExists(Test2::class.java, "getTest", Any::class.java)
|
||||
checkMethodExists(Test2::class.java, "setTest", Any::class.java, Any::class.java)
|
||||
checkMethodExists(Test2::class.java, "setTest", String::class.java, String::class.java)
|
||||
|
||||
checkNoMethod(TestClass::class.java, "getTest", String::class.java)
|
||||
checkNoMethod(TestClass::class.java, "getTest", Any::class.java)
|
||||
checkNoMethod(TestClass::class.java, "setTest", Any::class.java, Any::class.java)
|
||||
checkNoMethod(TestClass::class.java, "setTest", String::class.java, String::class.java)
|
||||
|
||||
try {
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkNoMethod(test2DefaultImpls, "getTest", Test2::class.java, String::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "getTest", Test2::class.java, Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "setTest", Test2::class.java, Any::class.java, Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "setTest", Test2::class.java, String::class.java, String::class.java)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
//or no class
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
|
||||
fun checkMethodExists(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
return
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
throw AssertionError("fail: method $name was not found in " + clazz, e)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// TARGET_BACKEND: JVM
|
||||
// JVM_TARGET: 1.8
|
||||
// WITH_RUNTIME
|
||||
// FULL_JDK
|
||||
|
||||
// FILE: Test.java
|
||||
|
||||
public interface Test<T> {
|
||||
default T test(T p) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: kotlin.kt
|
||||
|
||||
interface Test2: Test<String> {
|
||||
override fun test(p: String): String {
|
||||
return p
|
||||
}
|
||||
|
||||
fun forDefaultImpls() {}
|
||||
}
|
||||
|
||||
class TestClass : Test2
|
||||
|
||||
fun box(): String {
|
||||
checkMethodExists(Test2::class.java, "test", String::class.java)
|
||||
checkMethodExists(Test2::class.java, "test", Any::class.java)
|
||||
|
||||
checkNoMethod(TestClass::class.java, "test", String::class.java)
|
||||
checkNoMethod(TestClass::class.java, "test", Any::class.java)
|
||||
|
||||
try {
|
||||
val test2DefaultImpls = java.lang.Class.forName("Test2\$DefaultImpls")
|
||||
checkNoMethod(test2DefaultImpls, "test", Any::class.java)
|
||||
checkNoMethod(test2DefaultImpls, "test", String::class.java)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
//or no class at all
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun checkNoMethod(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
return
|
||||
}
|
||||
throw AssertionError("fail: method $name was found in " + clazz)
|
||||
}
|
||||
|
||||
fun checkMethodExists(clazz: Class<*>, name: String, vararg parameterTypes: Class<*>) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(name, *parameterTypes)
|
||||
return
|
||||
}
|
||||
catch (e: NoSuchMethodException) {
|
||||
throw AssertionError("fail: method $name was not found in " + clazz, e)
|
||||
}
|
||||
|
||||
}
|
||||
+60
@@ -16153,6 +16153,36 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInClass.kt")
|
||||
public void testBridgeInClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface.kt")
|
||||
public void testBridgeInInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface2.kt")
|
||||
public void testBridgeInInterface2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties.kt")
|
||||
public void testBridgeInInterfaceWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties2.kt")
|
||||
public void testBridgeInInterfaceWithProperties2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithJava.kt")
|
||||
public void testBridgeWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithProperties.kt")
|
||||
public void testBridgeWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties.kt");
|
||||
@@ -16352,6 +16382,36 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInClass.kt")
|
||||
public void testBridgeInClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface.kt")
|
||||
public void testBridgeInInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface2.kt")
|
||||
public void testBridgeInInterface2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties.kt")
|
||||
public void testBridgeInInterfaceWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties2.kt")
|
||||
public void testBridgeInInterfaceWithProperties2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithJava.kt")
|
||||
public void testBridgeWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithProperties.kt")
|
||||
public void testBridgeWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties.kt");
|
||||
|
||||
+60
@@ -16153,6 +16153,36 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInClass.kt")
|
||||
public void testBridgeInClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface.kt")
|
||||
public void testBridgeInInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface2.kt")
|
||||
public void testBridgeInInterface2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties.kt")
|
||||
public void testBridgeInInterfaceWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties2.kt")
|
||||
public void testBridgeInInterfaceWithProperties2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithJava.kt")
|
||||
public void testBridgeWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithProperties.kt")
|
||||
public void testBridgeWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties.kt");
|
||||
@@ -16352,6 +16382,36 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInClass.kt")
|
||||
public void testBridgeInClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface.kt")
|
||||
public void testBridgeInInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface2.kt")
|
||||
public void testBridgeInInterface2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties.kt")
|
||||
public void testBridgeInInterfaceWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties2.kt")
|
||||
public void testBridgeInInterfaceWithProperties2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithJava.kt")
|
||||
public void testBridgeWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithProperties.kt")
|
||||
public void testBridgeWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties.kt");
|
||||
|
||||
+60
@@ -14938,6 +14938,36 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridge3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInClass.kt")
|
||||
public void testBridgeInClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface.kt")
|
||||
public void testBridgeInInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface2.kt")
|
||||
public void testBridgeInInterface2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterface2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties.kt")
|
||||
public void testBridgeInInterfaceWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties2.kt")
|
||||
public void testBridgeInInterfaceWithProperties2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeInInterfaceWithProperties2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithJava.kt")
|
||||
public void testBridgeWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithProperties.kt")
|
||||
public void testBridgeWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/bridgeWithProperties.kt");
|
||||
@@ -15137,6 +15167,36 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridge3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInClass.kt")
|
||||
public void testBridgeInClass() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface.kt")
|
||||
public void testBridgeInInterface() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterface2.kt")
|
||||
public void testBridgeInInterface2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterface2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties.kt")
|
||||
public void testBridgeInInterfaceWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeInInterfaceWithProperties2.kt")
|
||||
public void testBridgeInInterfaceWithProperties2() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeInInterfaceWithProperties2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithJava.kt")
|
||||
public void testBridgeWithJava() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("bridgeWithProperties.kt")
|
||||
public void testBridgeWithProperties() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/bridgeWithProperties.kt");
|
||||
|
||||
Reference in New Issue
Block a user