Switch warning to error for java-default method calls within 1.6 target

#KT-15825 Fixed

(cherry picked from commit 9b29ebb)
This commit is contained in:
Mikhael Bogdanov
2017-08-04 09:35:15 +02:00
committed by Ilya Gorbunov
parent 5bfa9b248e
commit 232d1bd9ef
7 changed files with 9 additions and 2 deletions
@@ -115,7 +115,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
"Please make explicit overrides (abstract or concrete) for the following non-abstract members of ''{1}'': {2}", "Please make explicit overrides (abstract or concrete) for the following non-abstract members of ''{1}'': {2}",
NAME, NAME, STRING); NAME, NAME, STRING);
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, "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, "Calls to static methods in Java interfaces are deprecated 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); 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);
@@ -96,7 +96,7 @@ public interface ErrorsJvm {
DiagnosticFactory3<PsiElement, DeclarationDescriptor, DeclarationDescriptor, String> TARGET6_INTERFACE_INHERITANCE = DiagnosticFactory3.create(ERROR); DiagnosticFactory3<PsiElement, DeclarationDescriptor, DeclarationDescriptor, String> TARGET6_INTERFACE_INHERITANCE = DiagnosticFactory3.create(ERROR);
DiagnosticFactory0<PsiElement> DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING); DiagnosticFactory0<PsiElement> DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING); DiagnosticFactory0<PsiElement> INTERFACE_STATIC_METHOD_CALL_FROM_JAVA6_TARGET = DiagnosticFactory0.create(WARNING);
DiagnosticFactory2<PsiElement, String, String> INLINE_FROM_HIGHER_PLATFORM = DiagnosticFactory2.create(ERROR); DiagnosticFactory2<PsiElement, String, String> INLINE_FROM_HIGHER_PLATFORM = DiagnosticFactory2.create(ERROR);
@@ -11,6 +11,7 @@ open class Base {
fun foo() = "OK" fun foo() = "OK"
} }
@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET")
class C : Base(), IBase { class C : Base(), IBase {
val lambda1 = { val lambda1 = {
super.foo() super.foo()
+1
View File
@@ -15,6 +15,7 @@ interface KInterface {
} }
class Test : Simple { class Test : Simple {
@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET")
fun bar(): String { fun bar(): String {
return super.test() return super.test()
} }
@@ -13,12 +13,14 @@ interface KInterface : Test {
} }
class KClass : Test { class KClass : Test {
@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET")
fun ktest(): String { fun ktest(): String {
return super.test() + test() return super.test() + test()
} }
} }
class KTClass : KInterface { class KTClass : KInterface {
@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET")
fun ktest(): String { fun ktest(): String {
return super.test() + test() return super.test() + test()
} }
@@ -27,6 +29,7 @@ class KTClass : KInterface {
fun box(): String { fun box(): String {
val p = object : KInterface { val p = object : KInterface {
@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET")
fun ktest(): String { fun ktest(): String {
return super.test() + test() return super.test() + test()
} }
@@ -15,6 +15,7 @@ interface K2 : K1
interface K3 : K2 interface K3 : K2
class C : K3 { class C : K3 {
@kotlin.Suppress("DEFAULT_METHOD_CALL_FROM_JAVA6_TARGET")
override fun foo() = super.foo() override fun foo() = super.foo()
} }
@@ -1,3 +1,4 @@
// ERROR: Super calls to Java default methods are prohibited in JVM target 1.6. Recompile with '-jvm-target 1.8'
import java.util.stream.Stream import java.util.stream.Stream
abstract class A : List<String> { abstract class A : List<String> {