From 591de36666bde7e97188b485d538196084679044 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Tue, 17 Jan 2017 14:10:04 +0100 Subject: [PATCH] Added deprecated diagnostic for invoking default methods within jvm-target 1.6 --- .../InterfaceDefaultMethodCallChecker.kt | 37 +++++++-- .../diagnostics/DefaultErrorMessagesJvm.java | 3 + .../resolve/jvm/diagnostics/ErrorsJvm.java | 3 + .../jvm8/interfaceFlag/superCallIndirect.kt | 26 ++++++ .../diagnostics/tests/j+k/traitDefaultCall.kt | 23 +++++- .../tests/j+k/traitDefaultCall.txt | 20 +++++ .../testsWithJava8/defaultMethods.kt | 70 ++++++++++++++++ .../testsWithJava8/defaultMethods.txt | 66 ++++++++++++++++ .../defaultMethodsIndirectInheritance.kt | 79 +++++++++++++++++++ .../defaultMethodsIndirectInheritance.txt | 74 +++++++++++++++++ .../testsWithJava8/staticMethodInClass.kt | 16 ++++ .../testsWithJava8/staticMethodInClass.txt | 13 +++ .../inheritanceStaticMethodFromInterface.kt | 2 +- .../targetedBuiltIns/blackListed.kt | 2 +- .../testsWithJava8/targetedBuiltIns/stream.kt | 2 +- .../DiagnosticsWithJava8TestGenerated.java | 18 +++++ ...BlackBoxWithJava8CodegenTestGenerated.java | 6 ++ 17 files changed, 446 insertions(+), 14 deletions(-) create mode 100644 compiler/testData/codegen/java8/box/jvm8/interfaceFlag/superCallIndirect.kt create mode 100644 compiler/testData/diagnostics/testsWithJava8/defaultMethods.kt create mode 100644 compiler/testData/diagnostics/testsWithJava8/defaultMethods.txt create mode 100644 compiler/testData/diagnostics/testsWithJava8/defaultMethodsIndirectInheritance.kt create mode 100644 compiler/testData/diagnostics/testsWithJava8/defaultMethodsIndirectInheritance.txt create mode 100644 compiler/testData/diagnostics/testsWithJava8/staticMethodInClass.kt create mode 100644 compiler/testData/diagnostics/testsWithJava8/staticMethodInClass.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 49755a41c7a..e7105b55c4d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,14 @@ package org.jetbrains.kotlin.resolve.jvm.checkers import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.config.JVMConfigurationKeys +import org.jetbrains.kotlin.config.JvmTarget +import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.ClassifierDescriptor -import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor +import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor import org.jetbrains.kotlin.resolve.DescriptorUtils +import org.jetbrains.kotlin.resolve.DescriptorUtils.* import org.jetbrains.kotlin.resolve.calls.callResolverUtil.getSuperCallExpression import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext @@ -27,19 +32,35 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm class InterfaceDefaultMethodCallChecker : CallChecker { + override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) { + val supportDefaults = context.compilerConfiguration.get(JVMConfigurationKeys.JVM_TARGET) == JvmTarget.JVM_1_8 + + val descriptor = resolvedCall.resultingDescriptor as? FunctionDescriptor ?: return + + if (!supportDefaults && + isStaticDeclaration(descriptor) && + isInterface(descriptor.containingDeclaration) && + descriptor is JavaCallableMemberDescriptor) { + context.trace.report(ErrorsJvm.INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET.on(reportOn)) + } + if (getSuperCallExpression(resolvedCall.call) == null) return - val targetDescriptor = resolvedCall.resultingDescriptor.original - val containerDescriptor = targetDescriptor.containingDeclaration + if (!isInterface(descriptor.original.containingDeclaration)) return - if (containerDescriptor is JavaClassDescriptor && DescriptorUtils.isInterface(containerDescriptor)) { - //is java interface default method called from trait + val realDescriptor = unwrapFakeOverride(descriptor) + val realDescriptorOwner = realDescriptor.containingDeclaration as? ClassDescriptor ?: return + + if (isInterface(realDescriptorOwner) && realDescriptor is JavaCallableMemberDescriptor) { 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)) } + else if (!supportDefaults) { + context.trace.report(ErrorsJvm.DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET.on(reportOn)) + } } } -} +} \ No newline at end of file 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 f32deb6604c..e9cb3e71716 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 @@ -112,6 +112,9 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension { "Method implementation inheritance is restricted for such cases. " + "Please make explicit overrides (abstract or concrete) for the following non-abstract members of ''{1}'': {2}", Renderers.NAME, Renderers.NAME, Renderers.TO_STRING); + + MAP.put(ErrorsJvm.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(ErrorsJvm.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''"); } @NotNull 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 b90ce68d6d6..a1f09d93c16 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 @@ -89,6 +89,9 @@ public interface ErrorsJvm { DiagnosticFactory3 TARGET6_INTERFACE_INHERITANCE = DiagnosticFactory3.create(ERROR); + DiagnosticFactory0 DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING); + DiagnosticFactory0 INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING); + @SuppressWarnings("UnusedDeclaration") Object _initializer = new Object() { { diff --git a/compiler/testData/codegen/java8/box/jvm8/interfaceFlag/superCallIndirect.kt b/compiler/testData/codegen/java8/box/jvm8/interfaceFlag/superCallIndirect.kt new file mode 100644 index 00000000000..fe23f4540a9 --- /dev/null +++ b/compiler/testData/codegen/java8/box/jvm8/interfaceFlag/superCallIndirect.kt @@ -0,0 +1,26 @@ +// FILE: Simple.java + +public interface Simple { + default String test() { + return "O"; + } + + static String testStatic() { + return "K"; + } +} + +// FILE: main.kt +// JVM_TARGET: 1.8 +interface KSimple : Simple {} + +class TestClass : KSimple { + override fun test(): String { + return super.test() + } +} + + +fun box(): String { + return TestClass().test() + Simple.testStatic() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.kt b/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.kt index 1c0f1eeec22..9eb63670f65 100644 --- a/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.kt +++ b/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.kt @@ -15,9 +15,26 @@ interface KTrait : Test { } -class A : KTrait { - fun a() { - super.test() +interface KTrait2 : KTrait { + fun ktest2() { + super.test() + + test() + } +} + +class A : KTrait { + fun a() { + super.test() + + test() + } +} + + +class A2 : KTrait2 { + fun a() { + super.test() test() } diff --git a/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.txt b/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.txt index f66e4524501..780473dd8f6 100644 --- a/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.txt +++ b/compiler/testData/diagnostics/tests/j+k/traitDefaultCall.txt @@ -10,6 +10,17 @@ public final class A : KTrait { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } +public final class A2 : KTrait2 { + public constructor A2() + public final fun a(): kotlin.Unit + 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 ktest(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun ktest2(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun test(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + public interface KTrait : Test { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -18,6 +29,15 @@ public interface KTrait : Test { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } +public interface KTrait2 : KTrait { + 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 ktest(): kotlin.Unit + public open fun ktest2(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun test(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + public interface Test { public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithJava8/defaultMethods.kt b/compiler/testData/diagnostics/testsWithJava8/defaultMethods.kt new file mode 100644 index 00000000000..a33f8438eb9 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJava8/defaultMethods.kt @@ -0,0 +1,70 @@ +// 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/testsWithJava8/defaultMethods.txt b/compiler/testData/diagnostics/testsWithJava8/defaultMethods.txt new file mode 100644 index 00000000000..e46b079c6e2 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJava8/defaultMethods.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/testsWithJava8/defaultMethodsIndirectInheritance.kt b/compiler/testData/diagnostics/testsWithJava8/defaultMethodsIndirectInheritance.kt new file mode 100644 index 00000000000..ab22518d9ec --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJava8/defaultMethodsIndirectInheritance.kt @@ -0,0 +1,79 @@ +// FILE: JavaInterfaceBase.java + +public interface JavaInterfaceBase { + default String test() { + return "OK"; + } + + default String testOverride() { + return "OK"; + } +} + +// FILE: JavaInterface.java + +public interface JavaInterface extends JavaInterfaceBase { + static String testStatic() { + return "OK"; + } +} + + +// FILE: 1.kt +import JavaInterface.testStatic + +interface KotlinInterface : JavaInterface { + fun fooo() { + testStatic() + super.test() + test() + testOverride() + } + + override fun testOverride(): String { + return "OK"; + } +} + +interface KotlinInterfaceIndirectInheritance : KotlinInterface { + fun foooo() { + testStatic() + super.test() + testOverride() + super.testOverride() + } +} + +open class KotlinClass : JavaInterface { + fun foo(){ + testStatic() + super.test() + super.testOverride() + } +} + +class KotlinClassIndirectInheritance : KotlinClass() { + fun foo2(){ + testStatic() + super.test() + super.testOverride() + } +} + +class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { + fun foo(){ + testStatic() + super.test() + super.testOverride() + } +} + +fun test() { + JavaInterface.testStatic() + KotlinClass().foo() + KotlinClassIndirectInheritance2().foo() + + KotlinClass().test() + KotlinClass().testOverride() + KotlinClassIndirectInheritance().testOverride() +} diff --git a/compiler/testData/diagnostics/testsWithJava8/defaultMethodsIndirectInheritance.txt b/compiler/testData/diagnostics/testsWithJava8/defaultMethodsIndirectInheritance.txt new file mode 100644 index 00000000000..f2407057426 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJava8/defaultMethodsIndirectInheritance.txt @@ -0,0 +1,74 @@ +package + +public fun test(): kotlin.Unit + +public interface JavaInterface : JavaInterfaceBase { + 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.String! + public open override /*1*/ /*fake_override*/ fun testOverride(): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun testStatic(): kotlin.String! +} + +public interface JavaInterfaceBase { + 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 +} + +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 KotlinClassIndirectInheritance : KotlinClass { + public constructor KotlinClassIndirectInheritance() + 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 KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance { + public constructor KotlinClassIndirectInheritance2() + 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 KotlinInterfaceIndirectInheritance : 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/testsWithJava8/staticMethodInClass.kt b/compiler/testData/diagnostics/testsWithJava8/staticMethodInClass.kt new file mode 100644 index 00000000000..06c9a89809d --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJava8/staticMethodInClass.kt @@ -0,0 +1,16 @@ +// FILE: JavaClass.java + +public class JavaClass { + public static String testStatic() { + return "OK"; + } + +} + +// FILE: 1.kt +import JavaClass.testStatic + +fun test() { + JavaClass.testStatic() + testStatic() +} diff --git a/compiler/testData/diagnostics/testsWithJava8/staticMethodInClass.txt b/compiler/testData/diagnostics/testsWithJava8/staticMethodInClass.txt new file mode 100644 index 00000000000..0a00db727b6 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithJava8/staticMethodInClass.txt @@ -0,0 +1,13 @@ +package + +public fun test(): kotlin.Unit + +public open class JavaClass { + public constructor JavaClass() + 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 toString(): kotlin.String + + // Static members + public open fun testStatic(): kotlin.String! +} diff --git a/compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.kt b/compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.kt index 0ace11ee609..863102104de 100644 --- a/compiler/testData/diagnostics/testsWithJava8/statics/inheritanceStaticMethodFromInterface.kt +++ b/compiler/testData/diagnostics/testsWithJava8/statics/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/testsWithJava8/targetedBuiltIns/blackListed.kt b/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/blackListed.kt index 613518df00c..89672092620 100644 --- a/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/blackListed.kt +++ b/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/blackListed.kt @@ -1,6 +1,6 @@ abstract class A : MutableList { override fun sort(/*0*/ p0: java.util.Comparator) { - super.sort(p0) + super.sort(p0) } } diff --git a/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/stream.kt b/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/stream.kt index 4e086498528..13864af41c9 100644 --- a/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/stream.kt +++ b/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/stream.kt @@ -1,7 +1,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/tests-java8/tests/org/jetbrains/kotlin/checkers/DiagnosticsWithJava8TestGenerated.java b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/DiagnosticsWithJava8TestGenerated.java index 3b213f3e48c..a73b51f2b73 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/DiagnosticsWithJava8TestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/checkers/DiagnosticsWithJava8TestGenerated.java @@ -36,12 +36,30 @@ public class DiagnosticsWithJava8TestGenerated extends AbstractDiagnosticsWithFu KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJava8"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("defaultMethods.kt") + public void testDefaultMethods() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJava8/defaultMethods.kt"); + doTest(fileName); + } + + @TestMetadata("defaultMethodsIndirectInheritance.kt") + public void testDefaultMethodsIndirectInheritance() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJava8/defaultMethodsIndirectInheritance.kt"); + doTest(fileName); + } + @TestMetadata("samWithConsumer.kt") public void testSamWithConsumer() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJava8/samWithConsumer.kt"); doTest(fileName); } + @TestMetadata("staticMethodInClass.kt") + public void testStaticMethodInClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJava8/staticMethodInClass.kt"); + doTest(fileName); + } + @TestMetadata("compiler/testData/diagnostics/testsWithJava8/annotations") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) 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 e4ba1d402d7..abaadbdf6f5 100644 --- a/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java +++ b/compiler/tests-java8/tests/org/jetbrains/kotlin/codegen/BlackBoxWithJava8CodegenTestGenerated.java @@ -393,6 +393,12 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/interfaceFlag/superCall.kt"); doTest(fileName); } + + @TestMetadata("superCallIndirect.kt") + public void testSuperCallIndirect() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/jvm8/interfaceFlag/superCallIndirect.kt"); + doTest(fileName); + } } }