Extract diagnostics about an unsupported case of inheritance from Java

^KT-59152
This commit is contained in:
Mikhail Zarechenskiy
2023-06-07 14:06:45 +02:00
committed by Space Team
parent de78f52bc9
commit 1df4893a43
4 changed files with 8 additions and 4 deletions
@@ -36,9 +36,9 @@ object BadInheritedJavaSignaturesChecker : DeclarationChecker {
val renderedDescriptor = DescriptorRenderer.COMPACT_WITH_SHORT_TYPES.render(badSignatureOverriddenDescriptor)
context.trace.report(
Errors.UNSUPPORTED.on(
Errors.UNSUPPORTED_INHERITANCE_FROM_JAVA_MEMBER_REFERENCING_KOTLIN_FUNCTION.on(
reportOn,
"Inheritance of a Java member referencing '${JavaToKotlinClassMap.FUNCTION_N_FQ_NAME}': $renderedDescriptor"
renderedDescriptor
)
)
}
@@ -77,6 +77,8 @@ public interface Errors {
DiagnosticFactory0<KtElement> EXPLICIT_BACKING_FIELDS_UNSUPPORTED = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<PsiElement, String> UNSUPPORTED_INHERITANCE_FROM_JAVA_MEMBER_REFERENCING_KOTLIN_FUNCTION = DiagnosticFactory1.create(ERROR);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Generic errors/warnings: applicable in many contexts
@@ -825,6 +825,8 @@ public class DefaultErrorMessages {
MAP.put(EXPLICIT_BACKING_FIELDS_UNSUPPORTED, "Explicit backing field declarations are not supported in FE 1.0");
MAP.put(UNSUPPORTED_INHERITANCE_FROM_JAVA_MEMBER_REFERENCING_KOTLIN_FUNCTION, "Inheritance of a Java member referencing 'kotlin.jvm.functions.FunctionN': {0} is unsupported", STRING);
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
MAP.put(MISSING_STDLIB, "{0}. Ensure you have the standard Kotlin library in dependencies", STRING);
MAP.put(UNNECESSARY_SAFE_CALL, "Unnecessary safe call on a non-null receiver of type {0}", RENDER_TYPE);
@@ -9,8 +9,8 @@ public class A {
// FILE: main.kt
class <!UNSUPPORTED("Inheritance of a Java member referencing 'kotlin.jvm.functions.FunctionN': fun foo(w: FunctionN<*>!): Unit defined in A")!>B<!> : A()
class <!UNSUPPORTED_INHERITANCE_FROM_JAVA_MEMBER_REFERENCING_KOTLIN_FUNCTION!>B<!> : A()
fun foo() {
<!UNSUPPORTED("Inheritance of a Java member referencing 'kotlin.jvm.functions.FunctionN': fun foo(w: FunctionN<*>!): Unit defined in A")!>object<!> : A() {}
<!UNSUPPORTED_INHERITANCE_FROM_JAVA_MEMBER_REFERENCING_KOTLIN_FUNCTION!>object<!> : A() {}
}