Proper check NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT in new jvm-default modes
#KT-42699 Fixed
This commit is contained in:
+5
@@ -493,6 +493,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/javaOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaOverrideAll.kt")
|
||||
public void testJavaOverrideAll() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/javaOverrideAll.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmDefaultInInheritance.kt")
|
||||
public void testJvmDefaultInInheritance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultInInheritance.kt");
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ class JvmDefaultChecker(val jvmTarget: JvmTarget, project: Project) : Declaratio
|
||||
}
|
||||
|
||||
|
||||
if (isInterface(descriptor.containingDeclaration)) {
|
||||
if (!jvmDefaultMode.forAllMethodsWithBody && isInterface(descriptor.containingDeclaration)) {
|
||||
val memberDescriptor = descriptor as? CallableMemberDescriptor ?: return
|
||||
if (descriptor is PropertyAccessorDescriptor) return
|
||||
|
||||
|
||||
+1
-1
@@ -144,7 +144,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
|
||||
MAP.put(JVM_DEFAULT_IN_DECLARATION, "Usage of ''@{0}'' is only allowed with -Xjvm-default option", STRING);
|
||||
MAP.put(JVM_DEFAULT_THROUGH_INHERITANCE, "Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option");
|
||||
MAP.put(USAGE_OF_JVM_DEFAULT_THROUGH_SUPER_CALL, "Super calls of '@JvmDefault' members are only allowed with -Xjvm-default option");
|
||||
MAP.put(NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT, "Non-@JvmDefault interface method cannot override default Java method. Please annotate this method with @JvmDefault");
|
||||
MAP.put(NON_JVM_DEFAULT_OVERRIDES_JAVA_DEFAULT, "Non-@JvmDefault interface method cannot override default Java method. Please annotate this method with @JvmDefault or enable `-Xjvm-default=all|all-compatibility`");
|
||||
MAP.put(EXPLICIT_METADATA_IS_DISALLOWED, "Explicit @Metadata is disallowed");
|
||||
MAP.put(SUSPENSION_POINT_INSIDE_MONITOR, "A suspension point at {0} is inside a critical section", STRING);
|
||||
MAP.put(SUSPENSION_POINT_INSIDE_CRITICAL_SECTION, "The ''{0}'' suspension point is inside a critical section", NAME);
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
// FIR_IDENTICAL
|
||||
// !JVM_DEFAULT_MODE: all
|
||||
// !JVM_TARGET: 1.8
|
||||
|
||||
// FILE: JavaInterface.java
|
||||
public interface JavaInterface {
|
||||
default void test() {}
|
||||
|
||||
default void testForNonDefault() {}
|
||||
|
||||
void testAbstract();
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
interface KotlinInterface : JavaInterface {
|
||||
@JvmDefault
|
||||
override fun test() {}
|
||||
|
||||
override fun testForNonDefault() {}
|
||||
|
||||
override fun testAbstract() {}
|
||||
}
|
||||
|
||||
interface KotlinInterface2 : JavaInterface, KotlinInterface {
|
||||
override fun test() {}
|
||||
|
||||
override fun testForNonDefault() {}
|
||||
|
||||
override fun testAbstract() {}
|
||||
}
|
||||
|
||||
|
||||
interface KotlinInterfaceForIndirect : JavaInterface {
|
||||
|
||||
}
|
||||
|
||||
interface KotlinInterfaceIndirectInheritance : KotlinInterfaceForIndirect {
|
||||
|
||||
override fun test() {}
|
||||
|
||||
override fun testForNonDefault() {}
|
||||
|
||||
override fun testAbstract() {}
|
||||
}
|
||||
|
||||
open class KotlinClass : JavaInterface {
|
||||
override fun test() {}
|
||||
|
||||
override fun testForNonDefault() {}
|
||||
|
||||
override fun testAbstract() {}
|
||||
}
|
||||
|
||||
interface KotlinInterfaceX {
|
||||
|
||||
fun test() {}
|
||||
|
||||
fun testForNonDefault() {}
|
||||
|
||||
fun testAbstract() {}
|
||||
}
|
||||
|
||||
interface KotlinInterfaceManySuper: JavaInterface, KotlinInterfaceX {
|
||||
override fun test() {}
|
||||
|
||||
override fun testForNonDefault() {}
|
||||
|
||||
override fun testAbstract() {}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package
|
||||
|
||||
public interface JavaInterface {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open fun test(): kotlin.Unit
|
||||
public abstract fun testAbstract(): kotlin.Unit
|
||||
public open fun testForNonDefault(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public open class KotlinClass : JavaInterface {
|
||||
public constructor KotlinClass()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ fun testAbstract(): kotlin.Unit
|
||||
public open override /*1*/ fun testForNonDefault(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinInterface : JavaInterface {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@kotlin.jvm.JvmDefault public open override /*1*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ fun testAbstract(): kotlin.Unit
|
||||
public open override /*1*/ fun testForNonDefault(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinInterface2 : JavaInterface, KotlinInterface {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ fun test(): kotlin.Unit
|
||||
public open override /*2*/ fun testAbstract(): kotlin.Unit
|
||||
public open override /*2*/ fun testForNonDefault(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinInterfaceForIndirect : JavaInterface {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun test(): kotlin.Unit
|
||||
public abstract override /*1*/ /*fake_override*/ fun testAbstract(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun testForNonDefault(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinInterfaceIndirectInheritance : KotlinInterfaceForIndirect {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ fun test(): kotlin.Unit
|
||||
public open override /*1*/ fun testAbstract(): kotlin.Unit
|
||||
public open override /*1*/ fun testForNonDefault(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinInterfaceManySuper : JavaInterface, KotlinInterfaceX {
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ fun test(): kotlin.Unit
|
||||
public open override /*2*/ fun testAbstract(): kotlin.Unit
|
||||
public open override /*2*/ fun testForNonDefault(): kotlin.Unit
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinInterfaceX {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open fun test(): kotlin.Unit
|
||||
public open fun testAbstract(): kotlin.Unit
|
||||
public open fun testForNonDefault(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+5
@@ -493,6 +493,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/javaOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaOverrideAll.kt")
|
||||
public void testJavaOverrideAll() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/javaOverrideAll.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmDefaultInInheritance.kt")
|
||||
public void testJvmDefaultInInheritance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultInInheritance.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -493,6 +493,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/javaOverride.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("javaOverrideAll.kt")
|
||||
public void testJavaOverrideAll() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/javaOverrideAll.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmDefaultInInheritance.kt")
|
||||
public void testJvmDefaultInInheritance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmDefault/jvmDefaultInInheritance.kt");
|
||||
|
||||
+5
-5
@@ -14759,11 +14759,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/anySuperCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fieldNameClash.kt")
|
||||
public void ignoreFieldNameClash() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithCustomEquals.kt")
|
||||
public void ignoreInlineClassWithCustomEquals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassWithCustomEquals.kt");
|
||||
@@ -15067,6 +15062,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/extLambdaInInlineClassFun2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fieldNameClash.kt")
|
||||
public void testFieldNameClash() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
||||
|
||||
Reference in New Issue
Block a user