Skip java defaults in EXPLICIT_OVERRIDE_REQUIRED_IN_MIXED_MODE check

#KT-42674 Fixed
This commit is contained in:
Mikhael Bogdanov
2020-10-15 10:10:47 +02:00
parent a60febbdfb
commit b6dc99b98e
9 changed files with 192 additions and 1 deletions
@@ -16302,6 +16302,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/jvm8/defaults/kt40920.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/kt42674.kt");
}
@TestMetadata("oneImplementation.kt")
public void testOneImplementation() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/oneImplementation.kt");
@@ -16464,6 +16469,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/kt14243_2.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/kt42674.kt");
}
@TestMetadata("privateFunInInterface.kt")
public void testPrivateFunInInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/privateFunInInterface.kt");
@@ -16575,6 +16585,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/interfaceExtension.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/kt42674.kt");
}
@TestMetadata("propertyAnnotation.kt")
public void testPropertyAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/propertyAnnotation.kt");
@@ -16736,6 +16751,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt40920.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt42674.kt");
}
@TestMetadata("privateFunInInterface.kt")
public void testPrivateFunInInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/privateFunInInterface.kt");
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.config.JvmAnalysisFlags
import org.jetbrains.kotlin.config.JvmDefaultMode
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
import org.jetbrains.kotlin.load.kotlin.computeJvmDescriptor
import org.jetbrains.kotlin.psi.KtDeclaration
@@ -200,7 +201,11 @@ class JvmDefaultChecker(val jvmTarget: JvmTarget, project: Project) : Declaratio
val classMembers =
inheritedFun.overriddenDescriptors.filter { !isInterface(it.containingDeclaration) && !isAnnotationClass(it.containingDeclaration) }
val implicitDefaultImplsDelegate =
classMembers.firstOrNull { getNonPrivateTraitMembersForDelegation(it, true)?.isCompiledToJvmDefaultWithProperMode(jvmDefaultMode) == false }
classMembers.firstOrNull {
//TODO: additional processing for platform dependent method is required (https://youtrack.jetbrains.com/issue/KT-42697)
it !is JavaCallableMemberDescriptor &&
getNonPrivateTraitMembersForDelegation(it, true)?.isCompiledToJvmDefaultWithProperMode(jvmDefaultMode) == false
}
if (implicitDefaultImplsDelegate != null) return implicitDefaultImplsDelegate
return classMembers.firstNotNullResult { findPossibleClashMember(it, jvmDefaultMode) }
}
@@ -0,0 +1,26 @@
// !JVM_DEFAULT_MODE: all-compatibility
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_RUNTIME
// FILE: A.java
public interface A {
default String foo() {
return "fail";
}
}
// FILE: B.java
public abstract class B implements A {}
// FILE: test.kt
interface KDefault : A {
override fun foo() = "OK"
}
class Problem : B(), KDefault
fun box(): String {
return Problem().foo()
}
@@ -0,0 +1,27 @@
// !JVM_DEFAULT_MODE: compatibility
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_RUNTIME
// FILE: A.java
public interface A {
default String foo() {
return "fail";
}
}
// FILE: B.java
public abstract class B implements A {}
// FILE: test.kt
interface KDefault : A {
@JvmDefault
override fun foo() = "OK"
}
class Problem : B(), KDefault
fun box(): String {
return Problem().foo()
}
+27
View File
@@ -0,0 +1,27 @@
// !JVM_DEFAULT_MODE: enable
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_RUNTIME
// FILE: A.java
public interface A {
default String foo() {
return "fail";
}
}
// FILE: B.java
public abstract class B implements A {}
// FILE: test.kt
interface KDefault : A {
@JvmDefault
override fun foo() = "OK"
}
class Problem : B(), KDefault
fun box(): String {
return Problem().foo()
}
@@ -0,0 +1,26 @@
// !JVM_DEFAULT_MODE: all
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_RUNTIME
// FILE: A.java
public interface A {
default String foo() {
return "fail";
}
}
// FILE: B.java
public abstract class B implements A {}
// FILE: test.kt
interface KDefault : A {
override fun foo() = "OK"
}
class Problem : B(), KDefault
fun box(): String {
return Problem().foo()
}
@@ -17697,6 +17697,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/jvm8/defaults/kt40920.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/kt42674.kt");
}
@TestMetadata("oneImplementation.kt")
public void testOneImplementation() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/oneImplementation.kt");
@@ -17859,6 +17864,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/kt14243_2.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/kt42674.kt");
}
@TestMetadata("privateFunInInterface.kt")
public void testPrivateFunInInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/privateFunInInterface.kt");
@@ -17970,6 +17980,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/interfaceExtension.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/kt42674.kt");
}
@TestMetadata("propertyAnnotation.kt")
public void testPropertyAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/propertyAnnotation.kt");
@@ -18131,6 +18146,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt40920.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt42674.kt");
}
@TestMetadata("privateFunInInterface.kt")
public void testPrivateFunInInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/privateFunInInterface.kt");
@@ -17697,6 +17697,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/jvm8/defaults/kt40920.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/kt42674.kt");
}
@TestMetadata("oneImplementation.kt")
public void testOneImplementation() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/oneImplementation.kt");
@@ -17859,6 +17864,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/kt14243_2.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/kt42674.kt");
}
@TestMetadata("privateFunInInterface.kt")
public void testPrivateFunInInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/privateFunInInterface.kt");
@@ -17970,6 +17980,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/interfaceExtension.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/kt42674.kt");
}
@TestMetadata("propertyAnnotation.kt")
public void testPropertyAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/propertyAnnotation.kt");
@@ -18131,6 +18146,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt40920.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt42674.kt");
}
@TestMetadata("privateFunInInterface.kt")
public void testPrivateFunInInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/privateFunInInterface.kt");
@@ -16302,6 +16302,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/jvm8/defaults/kt40920.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/kt42674.kt");
}
@TestMetadata("oneImplementation.kt")
public void testOneImplementation() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/oneImplementation.kt");
@@ -16464,6 +16469,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/kt14243_2.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/kt42674.kt");
}
@TestMetadata("privateFunInInterface.kt")
public void testPrivateFunInInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/allCompatibility/privateFunInInterface.kt");
@@ -16575,6 +16585,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/interfaceExtension.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/kt42674.kt");
}
@TestMetadata("propertyAnnotation.kt")
public void testPropertyAnnotation() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/compatibility/propertyAnnotation.kt");
@@ -16736,6 +16751,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt40920.kt");
}
@TestMetadata("kt42674.kt")
public void testKt42674() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/kt42674.kt");
}
@TestMetadata("privateFunInInterface.kt")
public void testPrivateFunInInterface() throws Exception {
runTest("compiler/testData/codegen/box/jvm8/defaults/noDefaultImpls/privateFunInInterface.kt");