Extract diagnostics about 'sealed fun interface' to a separate one

^KT-59152
This commit is contained in:
Mikhail Zarechenskiy
2023-06-07 14:40:59 +02:00
committed by Space Team
parent d772126f2c
commit 2dfdd8dcf6
4 changed files with 5 additions and 3 deletions
@@ -79,6 +79,7 @@ public interface Errors {
DiagnosticFactory1<PsiElement, String> UNSUPPORTED_INHERITANCE_FROM_JAVA_MEMBER_REFERENCING_KOTLIN_FUNCTION = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<PsiElement> UNSUPPORTED_SEALED_WHEN = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> UNSUPPORTED_SEALED_FUN_INTERFACE = DiagnosticFactory0.create(ERROR);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -827,6 +827,7 @@ public class DefaultErrorMessages {
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(UNSUPPORTED_SEALED_WHEN, "'sealed' in front of 'when' is reserved");
MAP.put(UNSUPPORTED_SEALED_FUN_INTERFACE, "'sealed fun interface' is unsupported");
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);
@@ -18,7 +18,7 @@ object SealedInterfaceAllowedChecker : DeclarationChecker {
val keyword = declaration.modifierList?.getModifier(KtTokens.SEALED_KEYWORD) ?: return
val diagnostic = if (context.languageVersionSettings.supportsFeature(LanguageFeature.SealedInterfaces)) {
if (descriptor.isFun) {
Errors.UNSUPPORTED.on(keyword, "sealed fun interfaces")
Errors.UNSUPPORTED_SEALED_FUN_INTERFACE.on(keyword)
} else return
} else {
Errors.UNSUPPORTED_FEATURE.on(keyword, LanguageFeature.SealedInterfaces to context.languageVersionSettings)
@@ -1,9 +1,9 @@
<!UNSUPPORTED!>sealed<!> fun interface A { // error
<!UNSUPPORTED_SEALED_FUN_INTERFACE!>sealed<!> fun interface A { // error
fun foo()
}
sealed interface Base {
<!UNSUPPORTED!>sealed<!> fun interface Derived : Base { // error
<!UNSUPPORTED_SEALED_FUN_INTERFACE!>sealed<!> fun interface Derived : Base { // error
fun foo()
}
}