From a547019ed0143ff5e1643e5c0a524427d239dd51 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Thu, 16 Nov 2017 16:48:32 +0100 Subject: [PATCH] Switch DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET according to LL --- .../InterfaceDefaultMethodCallChecker.kt | 14 ++-- .../diagnostics/DefaultErrorMessagesJvm.java | 4 +- .../resolve/jvm/diagnostics/ErrorsJvm.java | 4 +- .../codegen/java8/box/capturedSuperCall.kt | 2 +- .../box/defaultMethodCallFromInterface.kt | 2 +- .../java8/box/defaultMethodCallViaClass.kt | 2 +- .../box/defaultMethodCallViaInterface.kt | 2 +- .../codegen/java8/box/inheritKotlin.kt | 3 +- .../java8/box/invokeDefaultViaSuper.kt | 5 +- .../java8/box/invokeDefaultViaSuper_16.kt | 45 ++++++++++++ ...ChainOfKotlinExtendsFromJavaWithDefault.kt | 3 +- compiler/testData/codegen/java8/box/stream.kt | 1 + .../diagnostics/tests/generics/kt9203.kt | 2 +- .../diagnostics/tests/j+k/defaultMethods.kt | 18 ++--- .../j+k/defaultMethodsIndirectInheritance.kt | 18 ++--- .../tests/j+k/defaultMethods_warning.kt | 72 +++++++++++++++++++ .../tests/j+k/defaultMethods_warning.txt | 66 +++++++++++++++++ .../inheritanceStaticMethodFromInterface.kt | 2 +- .../diagnostics/tests/j+k/traitDefaultCall.kt | 4 +- .../tests/targetedBuiltIns/stream.kt | 2 +- .../targetedBuiltIns/blackListed.kt | 2 +- ...BlackBoxWithJava8CodegenTestGenerated.java | 6 ++ .../checkers/DiagnosticsTestGenerated.java | 6 ++ .../DiagnosticsUsingJavacTestGenerated.java | 6 ++ .../kotlin/config/LanguageVersionSettings.kt | 1 + 25 files changed, 250 insertions(+), 42 deletions(-) create mode 100644 compiler/testData/codegen/java8/box/invokeDefaultViaSuper_16.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.kt create mode 100644 compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.txt diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/InterfaceDefaultMethodCallChecker.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/InterfaceDefaultMethodCallChecker.kt index 4c0d8be106a..335b8af4b53 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/InterfaceDefaultMethodCallChecker.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/InterfaceDefaultMethodCallChecker.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.jvm.checkers import com.intellij.psi.PsiElement import org.jetbrains.kotlin.config.JvmTarget +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassifierDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor @@ -28,7 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getSuperCallExpressio import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall -import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm.* class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker { @@ -41,7 +42,8 @@ class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker isStaticDeclaration(descriptor) && isInterface(descriptor.containingDeclaration) && descriptor is JavaCallableMemberDescriptor) { - context.trace.report(ErrorsJvm.INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET.on(reportOn)) + val diagnostic = if (isDefaultCallsProhibited(context)) INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR else INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET + context.trace.report(diagnostic.on(reportOn)) } if (getSuperCallExpression(resolvedCall.call) == null) return @@ -55,11 +57,15 @@ class InterfaceDefaultMethodCallChecker(val jvmTarget: JvmTarget) : CallChecker val classifier = DescriptorUtils.getParentOfType(context.scope.ownerDescriptor, ClassifierDescriptor::class.java) //is java interface default method called from trait if (classifier != null && DescriptorUtils.isInterface(classifier)) { - context.trace.report(ErrorsJvm.INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER.on(reportOn)) + context.trace.report(INTERFACE_CANT_CALL_DEFAULT_METHOD_VIA_SUPER.on(reportOn)) } else if (!supportDefaults) { - context.trace.report(ErrorsJvm.DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET.on(reportOn)) + val diagnostic = if (isDefaultCallsProhibited(context)) DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR else DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET + context.trace.report(diagnostic.on(reportOn)) } } } + + private fun isDefaultCallsProhibited(context: CallCheckerContext) = + context.languageVersionSettings.supportsFeature(LanguageFeature.DefaultMethodsCallFromJava6TargetError) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java index 6f249ef36da..81f54c6afc1 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/DefaultErrorMessagesJvm.java @@ -115,8 +115,10 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { "Please make explicit overrides (abstract or concrete) for the following non-abstract members of ''{1}'': {2}", NAME, NAME, STRING); - MAP.put(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET, "Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"); + MAP.put(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET, "Super calls to Java default methods are deprecated in JVM target 1.6. Recompile with '-jvm-target 1.8'"); + MAP.put(DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR, "Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"); MAP.put(INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET, "Calls to static methods in Java interfaces are deprecated in JVM target 1.6. Recompile with '-jvm-target 1.8'"); + MAP.put(INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR, "Calls to static methods in Java interfaces are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'"); MAP.put(INLINE_FROM_HIGHER_PLATFORM, "Cannot inline bytecode built with {0} into bytecode that is being built with {1}. Please specify proper ''-jvm-target'' option", STRING, STRING); diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java index 4a4ff69b75e..8f6a7cdf799 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/diagnostics/ErrorsJvm.java @@ -96,8 +96,10 @@ public interface ErrorsJvm { DiagnosticFactory3 TARGET6_INTERFACE_INHERITANCE = DiagnosticFactory3.create(ERROR); - DiagnosticFactory0 DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(ERROR); + DiagnosticFactory0 DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET_ERROR = DiagnosticFactory0.create(ERROR); DiagnosticFactory2 INLINE_FROM_HIGHER_PLATFORM = DiagnosticFactory2.create(ERROR); diff --git a/compiler/testData/codegen/java8/box/capturedSuperCall.kt b/compiler/testData/codegen/java8/box/capturedSuperCall.kt index 5991b0bf5e1..6e63d2f8515 100644 --- a/compiler/testData/codegen/java8/box/capturedSuperCall.kt +++ b/compiler/testData/codegen/java8/box/capturedSuperCall.kt @@ -7,11 +7,11 @@ interface IBase { } // FILE: Kotlin.kt +// JVM_TARGET: 1.8 open class Base { fun foo() = "OK" } -@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET") class C : Base(), IBase { val lambda1 = { super.foo() diff --git a/compiler/testData/codegen/java8/box/defaultMethodCallFromInterface.kt b/compiler/testData/codegen/java8/box/defaultMethodCallFromInterface.kt index 5bfa5f60b0d..b656129343d 100644 --- a/compiler/testData/codegen/java8/box/defaultMethodCallFromInterface.kt +++ b/compiler/testData/codegen/java8/box/defaultMethodCallFromInterface.kt @@ -11,7 +11,7 @@ public interface Simple { } // FILE: main.kt - +// JVM_TARGET: 1.8 interface KInterface : Simple { fun bar(): String { return test("O") + Simple.testStatic("O") diff --git a/compiler/testData/codegen/java8/box/defaultMethodCallViaClass.kt b/compiler/testData/codegen/java8/box/defaultMethodCallViaClass.kt index 2e5fba7dc1f..96bf5cc2056 100644 --- a/compiler/testData/codegen/java8/box/defaultMethodCallViaClass.kt +++ b/compiler/testData/codegen/java8/box/defaultMethodCallViaClass.kt @@ -11,7 +11,7 @@ interface Simple { } // FILE: main.kt - +// JVM_TARGET: 1.8 class Test : Simple {} fun box(): String { diff --git a/compiler/testData/codegen/java8/box/defaultMethodCallViaInterface.kt b/compiler/testData/codegen/java8/box/defaultMethodCallViaInterface.kt index 2151e66737e..955ae1419c5 100644 --- a/compiler/testData/codegen/java8/box/defaultMethodCallViaInterface.kt +++ b/compiler/testData/codegen/java8/box/defaultMethodCallViaInterface.kt @@ -11,7 +11,7 @@ public interface Simple { } // FILE: main.kt - +// JVM_TARGET: 1.8 interface TestInterface : Simple {} class Test : TestInterface {} diff --git a/compiler/testData/codegen/java8/box/inheritKotlin.kt b/compiler/testData/codegen/java8/box/inheritKotlin.kt index 78f37a582e0..6307933397b 100644 --- a/compiler/testData/codegen/java8/box/inheritKotlin.kt +++ b/compiler/testData/codegen/java8/box/inheritKotlin.kt @@ -7,7 +7,7 @@ interface Simple extends KInterface { } // FILE: main.kt - +// JVM_TARGET: 1.8 interface KInterface { fun test(): String { return "base"; @@ -15,7 +15,6 @@ interface KInterface { } class Test : Simple { - @kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET") fun bar(): String { return super.test() } diff --git a/compiler/testData/codegen/java8/box/invokeDefaultViaSuper.kt b/compiler/testData/codegen/java8/box/invokeDefaultViaSuper.kt index cce7b32f37b..c2b4392d6d4 100644 --- a/compiler/testData/codegen/java8/box/invokeDefaultViaSuper.kt +++ b/compiler/testData/codegen/java8/box/invokeDefaultViaSuper.kt @@ -7,20 +7,18 @@ public interface Test { } // FILE: test.kt - +// JVM_TARGET: 1.8 interface KInterface : Test { } class KClass : Test { - @kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET") fun ktest(): String { return super.test() + test() } } class KTClass : KInterface { - @kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET") fun ktest(): String { return super.test() + test() } @@ -29,7 +27,6 @@ class KTClass : KInterface { fun box(): String { val p = object : KInterface { - @kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET") fun ktest(): String { return super.test() + test() } diff --git a/compiler/testData/codegen/java8/box/invokeDefaultViaSuper_16.kt b/compiler/testData/codegen/java8/box/invokeDefaultViaSuper_16.kt new file mode 100644 index 00000000000..2e66f049092 --- /dev/null +++ b/compiler/testData/codegen/java8/box/invokeDefaultViaSuper_16.kt @@ -0,0 +1,45 @@ +// FILE: Test.java + +public interface Test { + default String test() { + return "OK"; + } +} + +// FILE: test.kt + +interface KInterface : Test { + +} + +class KClass : Test { + @kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR") + fun ktest(): String { + return super.test() + test() + } +} + +class KTClass : KInterface { + @kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR") + fun ktest(): String { + return super.test() + test() + } +} + + +fun box(): String { + val p = object : KInterface { + @kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET_ERROR") + fun ktest(): String { + return super.test() + test() + } + }.ktest() + + if (p != "OKOK") return "fail1: $p" + + if (KClass().ktest() != "OKOK") return "fail 2: ${KClass().ktest()}" + + if (KTClass().ktest() != "OKOK") return "fail 3: ${KTClass().ktest()}" + + return "OK" +} diff --git a/compiler/testData/codegen/java8/box/longChainOfKotlinExtendsFromJavaWithDefault.kt b/compiler/testData/codegen/java8/box/longChainOfKotlinExtendsFromJavaWithDefault.kt index 21a6dfd8a84..533963d6fa8 100644 --- a/compiler/testData/codegen/java8/box/longChainOfKotlinExtendsFromJavaWithDefault.kt +++ b/compiler/testData/codegen/java8/box/longChainOfKotlinExtendsFromJavaWithDefault.kt @@ -7,7 +7,7 @@ public interface Base { } // FILE: derived.kt - +// JVM_TARGET: 1.8 interface K1 : Base interface K2 : K1 @@ -15,7 +15,6 @@ interface K2 : K1 interface K3 : K2 class C : K3 { - @kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET") override fun foo() = super.foo() } diff --git a/compiler/testData/codegen/java8/box/stream.kt b/compiler/testData/codegen/java8/box/stream.kt index 4c5b064cc9b..78a706d2c9a 100644 --- a/compiler/testData/codegen/java8/box/stream.kt +++ b/compiler/testData/codegen/java8/box/stream.kt @@ -1,5 +1,6 @@ // FULL_JDK // WITH_RUNTIME +// LANGUAGE_VERSION: 1.1 import java.util.stream.* class B : List { diff --git a/compiler/testData/diagnostics/tests/generics/kt9203.kt b/compiler/testData/diagnostics/tests/generics/kt9203.kt index 60f8fa0a412..d01e331cbc3 100644 --- a/compiler/testData/diagnostics/tests/generics/kt9203.kt +++ b/compiler/testData/diagnostics/tests/generics/kt9203.kt @@ -4,7 +4,7 @@ import java.util.stream.Collectors import java.util.stream.IntStream fun main(args: Array) { - val xs = IntStream.range(0, 10).mapToObj { it.toString() } + val xs = IntStream.range(0, 10).mapToObj { it.toString() } .collect(Collectors.toList()) xs[0] } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/defaultMethods.kt b/compiler/testData/diagnostics/tests/j+k/defaultMethods.kt index a33f8438eb9..b229c78c8b3 100644 --- a/compiler/testData/diagnostics/tests/j+k/defaultMethods.kt +++ b/compiler/testData/diagnostics/tests/j+k/defaultMethods.kt @@ -19,7 +19,7 @@ import JavaInterface.testStatic interface KotlinInterface : JavaInterface { fun fooo() { - testStatic() + testStatic() super.test() } @@ -30,22 +30,22 @@ interface KotlinInterface : JavaInterface { interface KotlinInterfaceInderectInheritance : KotlinInterface { fun foooo() { - testStatic() + testStatic() super.test() } } open class KotlinClass : JavaInterface { fun foo(){ - testStatic() - super.test() - super.testOverride() + testStatic() + super.test() + super.testOverride() } } class KotlinClassInderectInheritance : KotlinClass() { fun foo2(){ - testStatic() + testStatic() super.test() super.testOverride() } @@ -53,14 +53,14 @@ class KotlinClassInderectInheritance : KotlinClass() { class KotlinClassInderectInheritance2 : KotlinInterfaceInderectInheritance { fun foo(){ - testStatic() - super.test() + testStatic() + super.test() super.testOverride() } } fun test() { - JavaInterface.testStatic() + JavaInterface.testStatic() KotlinClass().foo() KotlinClassInderectInheritance2().foo() diff --git a/compiler/testData/diagnostics/tests/j+k/defaultMethodsIndirectInheritance.kt b/compiler/testData/diagnostics/tests/j+k/defaultMethodsIndirectInheritance.kt index ab22518d9ec..c4b862e0bba 100644 --- a/compiler/testData/diagnostics/tests/j+k/defaultMethodsIndirectInheritance.kt +++ b/compiler/testData/diagnostics/tests/j+k/defaultMethodsIndirectInheritance.kt @@ -24,7 +24,7 @@ import JavaInterface.testStatic interface KotlinInterface : JavaInterface { fun fooo() { - testStatic() + testStatic() super.test() test() testOverride() @@ -37,7 +37,7 @@ interface KotlinInterface : JavaInterface { interface KotlinInterfaceIndirectInheritance : KotlinInterface { fun foooo() { - testStatic() + testStatic() super.test() testOverride() super.testOverride() @@ -46,15 +46,15 @@ interface KotlinInterfaceIndirectInheritance : KotlinInterface { open class KotlinClass : JavaInterface { fun foo(){ - testStatic() - super.test() - super.testOverride() + testStatic() + super.test() + super.testOverride() } } class KotlinClassIndirectInheritance : KotlinClass() { fun foo2(){ - testStatic() + testStatic() super.test() super.testOverride() } @@ -62,14 +62,14 @@ class KotlinClassIndirectInheritance : KotlinClass() { class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { fun foo(){ - testStatic() - super.test() + testStatic() + super.test() super.testOverride() } } fun test() { - JavaInterface.testStatic() + JavaInterface.testStatic() KotlinClass().foo() KotlinClassIndirectInheritance2().foo() diff --git a/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.kt b/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.kt new file mode 100644 index 00000000000..e9b718ae71c --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.kt @@ -0,0 +1,72 @@ +//!LANGUAGE: -DefaultMethodsCallFromJava6TargetError +// FILE: JavaInterface.java + +public interface JavaInterface { + static String testStatic() { + return "OK"; + } + + default String test() { + return "OK"; + } + + default String testOverride() { + return "OK"; + } +} + +// FILE: 1.kt + +import JavaInterface.testStatic + +interface KotlinInterface : JavaInterface { + fun fooo() { + testStatic() + super.test() + } + + override fun testOverride(): String { + return "OK"; + } +} + +interface KotlinInterfaceInderectInheritance : KotlinInterface { + fun foooo() { + testStatic() + super.test() + } +} + +open class KotlinClass : JavaInterface { + fun foo(){ + testStatic() + super.test() + super.testOverride() + } +} + +class KotlinClassInderectInheritance : KotlinClass() { + fun foo2(){ + testStatic() + super.test() + super.testOverride() + } +} + +class KotlinClassInderectInheritance2 : KotlinInterfaceInderectInheritance { + fun foo(){ + testStatic() + super.test() + super.testOverride() + } +} + +fun test() { + JavaInterface.testStatic() + KotlinClass().foo() + KotlinClassInderectInheritance2().foo() + + KotlinClass().test() + KotlinClass().testOverride() + KotlinClassInderectInheritance().testOverride() +} diff --git a/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.txt b/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.txt new file mode 100644 index 00000000000..e46b079c6e2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.txt @@ -0,0 +1,66 @@ +package + +public fun test(): kotlin.Unit + +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.String! + public open fun testOverride(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun testStatic(): 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 final fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun test(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun testOverride(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class KotlinClassInderectInheritance : KotlinClass { + public constructor KotlinClassInderectInheritance() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit + public final fun foo2(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun test(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun testOverride(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class KotlinClassInderectInheritance2 : KotlinInterfaceInderectInheritance { + public constructor KotlinClassInderectInheritance2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun fooo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun foooo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun test(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun testOverride(): kotlin.String + 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 fun fooo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun test(): kotlin.String! + public open override /*1*/ fun testOverride(): kotlin.String + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface KotlinInterfaceInderectInheritance : KotlinInterface { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun fooo(): kotlin.Unit + public open fun foooo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun test(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun testOverride(): kotlin.String + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/j+k/inheritanceStaticMethodFromInterface.kt b/compiler/testData/diagnostics/tests/j+k/inheritanceStaticMethodFromInterface.kt index 863102104de..670883426d6 100644 --- a/compiler/testData/diagnostics/tests/j+k/inheritanceStaticMethodFromInterface.kt +++ b/compiler/testData/diagnostics/tests/j+k/inheritanceStaticMethodFromInterface.kt @@ -18,7 +18,7 @@ class K : C() fun main(args: Array) { I.a - I.foo() + I.foo() C.a C.b diff --git a/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.kt b/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.kt index 9eb63670f65..6531848b7c6 100644 --- a/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.kt +++ b/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.kt @@ -25,7 +25,7 @@ interface KTrait2 : KTrait { class A : KTrait { fun a() { - super.test() + super.test() test() } @@ -34,7 +34,7 @@ class A : KTrait { class A2 : KTrait2 { fun a() { - super.test() + super.test() test() } diff --git a/compiler/testData/diagnostics/tests/targetedBuiltIns/stream.kt b/compiler/testData/diagnostics/tests/targetedBuiltIns/stream.kt index c4741ee9902..0792fa81854 100644 --- a/compiler/testData/diagnostics/tests/targetedBuiltIns/stream.kt +++ b/compiler/testData/diagnostics/tests/targetedBuiltIns/stream.kt @@ -3,7 +3,7 @@ import java.util.stream.* interface A : Collection { - override fun stream(): Stream = Stream.of() + override fun stream(): Stream = Stream.of() } fun foo(x: List, y: A) { diff --git a/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/blackListed.kt b/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/blackListed.kt index 7a74b6f6029..5738db9fc65 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/blackListed.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/targetedBuiltIns/blackListed.kt @@ -2,7 +2,7 @@ abstract class A : MutableList { override fun sort(/*0*/ p0: java.util.Comparator) { - super.sort(p0) + super.sort(p0) } } diff --git a/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java index 2890f421947..7f1ab7dfc50 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java @@ -102,6 +102,12 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg doTest(fileName); } + @TestMetadata("invokeDefaultViaSuper_16.kt") + public void testInvokeDefaultViaSuper_16() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/invokeDefaultViaSuper_16.kt"); + doTest(fileName); + } + @TestMetadata("longChainOfKotlinExtendsFromJavaWithDefault.kt") public void testLongChainOfKotlinExtendsFromJavaWithDefault() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/longChainOfKotlinExtendsFromJavaWithDefault.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 06a99df96b1..4445f3924cf 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -12370,6 +12370,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("defaultMethods_warning.kt") + public void testDefaultMethods_warning() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.kt"); + doTest(fileName); + } + @TestMetadata("differentFilename.kt") public void testDifferentFilename() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/differentFilename.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 306adad4127..ca2db51fae6 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -12370,6 +12370,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing doTest(fileName); } + @TestMetadata("defaultMethods_warning.kt") + public void testDefaultMethods_warning() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/defaultMethods_warning.kt"); + doTest(fileName); + } + @TestMetadata("differentFilename.kt") public void testDifferentFilename() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/differentFilename.kt"); diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index f859b49da73..a8e8c18ce17 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -64,6 +64,7 @@ enum class LanguageFeature( JvmPackageName(KOTLIN_1_2), AssigningArraysToVarargsInNamedFormInAnnotations(KOTLIN_1_2), ExpectedTypeFromCast(KOTLIN_1_2), + DefaultMethodsCallFromJava6TargetError(KOTLIN_1_2), BooleanElvisBoundSmartCasts(KOTLIN_1_3), ReturnsEffect(KOTLIN_1_3),