Proper concrete implementation filtering in java 8 interface case
This commit is contained in:
@@ -23,6 +23,12 @@ interface FunctionHandle {
|
|||||||
val isDeclaration: Boolean
|
val isDeclaration: Boolean
|
||||||
val isAbstract: Boolean
|
val isAbstract: Boolean
|
||||||
|
|
||||||
|
/** On finding concrete super declaration we should distinguish non-abstract java8/js default methods from
|
||||||
|
* class ones (see [findConcreteSuperDeclaration] method in bridges.kt).
|
||||||
|
* Note that interface methods with body compiled to jvm 8 target are assumed to be non-abstract in bridges method calculation
|
||||||
|
* (more details in [DescriptorBasedFunctionHandle.isBodyOwner] comment).*/
|
||||||
|
val isInterfaceDeclaration: Boolean
|
||||||
|
|
||||||
fun getOverridden(): Iterable<FunctionHandle>
|
fun getOverridden(): Iterable<FunctionHandle>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +114,7 @@ fun <Function : FunctionHandle> findConcreteSuperDeclaration(function: Function)
|
|||||||
}
|
}
|
||||||
result.removeAll(toRemove)
|
result.removeAll(toRemove)
|
||||||
|
|
||||||
val concreteRelevantDeclarations = result.filter { !it.isAbstract }
|
val concreteRelevantDeclarations = result.filter { !it.isAbstract && !it.isInterfaceDeclaration }
|
||||||
if (concreteRelevantDeclarations.size != 1) {
|
if (concreteRelevantDeclarations.size != 1) {
|
||||||
error("Concrete fake override $function should have exactly one concrete super-declaration: $concreteRelevantDeclarations")
|
error("Concrete fake override $function should have exactly one concrete super-declaration: $concreteRelevantDeclarations")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ class DescriptorBasedFunctionHandle(
|
|||||||
descriptor.modality == Modality.ABSTRACT ||
|
descriptor.modality == Modality.ABSTRACT ||
|
||||||
isBodyOwner(descriptor.containingDeclaration)
|
isBodyOwner(descriptor.containingDeclaration)
|
||||||
|
|
||||||
|
override val isInterfaceDeclaration: Boolean
|
||||||
|
get() = DescriptorUtils.isInterface(descriptor.containingDeclaration)
|
||||||
|
|
||||||
override fun getOverridden() = overridden
|
override fun getOverridden() = overridden
|
||||||
|
|
||||||
override fun hashCode(): Int {
|
override fun hashCode(): Int {
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// JVM_TARGET: 1.8
|
||||||
|
interface KCallable {
|
||||||
|
val returnType: String
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KCallableImpl : KCallable {
|
||||||
|
override val returnType: String
|
||||||
|
get() = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KCallableImpl2 : KCallableImpl
|
||||||
|
|
||||||
|
open class DescriptorBasedProperty : KCallableImpl
|
||||||
|
open class KProperty1Impl : DescriptorBasedProperty(), KCallableImpl2
|
||||||
|
open class KMutableProperty1Impl : KProperty1Impl(), KCallable
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return KMutableProperty1Impl().returnType
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// JVM_TARGET: 1.8
|
||||||
|
interface KCallable {
|
||||||
|
val returnType: String
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KCallableImpl : KCallable {
|
||||||
|
override val returnType: String
|
||||||
|
get() = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KProperty : KCallable
|
||||||
|
interface KPropertyImpl : KProperty, KCallableImpl
|
||||||
|
interface KMutableProperty : KProperty
|
||||||
|
interface KProperty1 : KProperty
|
||||||
|
interface KMutableProperty1 : KProperty1, KMutableProperty
|
||||||
|
interface KMutablePropertyImpl : KPropertyImpl
|
||||||
|
|
||||||
|
open class DescriptorBasedProperty : KCallableImpl
|
||||||
|
open class KProperty1Impl : DescriptorBasedProperty(), KProperty1, KPropertyImpl
|
||||||
|
open class KMutableProperty1Impl : KProperty1Impl(), KMutableProperty1, KMutablePropertyImpl
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return KMutableProperty1Impl().returnType
|
||||||
|
}
|
||||||
+12
@@ -145,6 +145,18 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("oneImplementation.kt")
|
||||||
|
public void testOneImplementation() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/oneImplementation.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("oneImplementation2.kt")
|
||||||
|
public void testOneImplementation2() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/oneImplementation2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("simpleCall.kt")
|
@TestMetadata("simpleCall.kt")
|
||||||
public void testSimpleCall() throws Exception {
|
public void testSimpleCall() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/simpleCall.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/simpleCall.kt");
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class BridgeTest : TestCase() {
|
|||||||
private class Fun(val text: String) : FunctionHandle {
|
private class Fun(val text: String) : FunctionHandle {
|
||||||
override val isDeclaration: Boolean get() = text[1] == 'D'
|
override val isDeclaration: Boolean get() = text[1] == 'D'
|
||||||
override val isAbstract: Boolean get() = text[0] == '-'
|
override val isAbstract: Boolean get() = text[0] == '-'
|
||||||
|
override val isInterfaceDeclaration: Boolean get() = false
|
||||||
val signature: Char get() = text[2]
|
val signature: Char get() = text[2]
|
||||||
|
|
||||||
val overriddenFunctions: MutableList<Fun> = arrayListOf()
|
val overriddenFunctions: MutableList<Fun> = arrayListOf()
|
||||||
|
|||||||
Reference in New Issue
Block a user