Deprecate ExtensionFunctionType on a non-function types
Related to KT-43527
This commit is contained in:
+1
@@ -288,6 +288,7 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
|
||||
val REPEATED_ANNOTATION_WARNING by warning<KtAnnotationEntry>()
|
||||
val NOT_A_CLASS by error<PsiElement>()
|
||||
val WRONG_EXTENSION_FUNCTION_TYPE by error<KtAnnotationEntry>()
|
||||
val WRONG_EXTENSION_FUNCTION_TYPE_WARNING by warning<KtAnnotationEntry>()
|
||||
}
|
||||
|
||||
val OPT_IN by object : DiagnosticGroup("OptIn") {
|
||||
|
||||
@@ -254,6 +254,7 @@ object FirErrors {
|
||||
val REPEATED_ANNOTATION_WARNING by warning0<KtAnnotationEntry>()
|
||||
val NOT_A_CLASS by error0<PsiElement>()
|
||||
val WRONG_EXTENSION_FUNCTION_TYPE by error0<KtAnnotationEntry>()
|
||||
val WRONG_EXTENSION_FUNCTION_TYPE_WARNING by warning0<KtAnnotationEntry>()
|
||||
|
||||
// OptIn
|
||||
val OPT_IN_USAGE by warning2<PsiElement, FqName, String>(SourceElementPositioningStrategies.REFERENCE_BY_QUALIFIED)
|
||||
|
||||
+9
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.checkers.type
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.context.CheckerContext
|
||||
import org.jetbrains.kotlin.fir.analysis.checkers.getAllowedAnnotationTargets
|
||||
@@ -33,7 +34,14 @@ object FirTypeAnnotationChecker : FirTypeRefChecker() {
|
||||
}
|
||||
}
|
||||
if (annotation.classId == StandardClassIds.Annotations.ExtensionFunctionType) {
|
||||
if (typeRef.type.isBuiltinFunctionalType(context.session) && typeRef.type.typeArguments.size <= 1) {
|
||||
if (!typeRef.type.isBuiltinFunctionalType(context.session)) {
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.ForbidExtensionFunctionTypeOnNonFunctionTypes)) {
|
||||
reporter.reportOn(annotation.source, FirErrors.WRONG_EXTENSION_FUNCTION_TYPE, context)
|
||||
} else {
|
||||
reporter.reportOn(annotation.source, FirErrors.WRONG_EXTENSION_FUNCTION_TYPE_WARNING, context)
|
||||
}
|
||||
|
||||
} else if (typeRef.type.typeArguments.size <= 1) {
|
||||
reporter.reportOn(annotation.source, FirErrors.WRONG_EXTENSION_FUNCTION_TYPE, context)
|
||||
}
|
||||
}
|
||||
|
||||
+9
-1
@@ -562,6 +562,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.VIRTUAL_MEMBER_HI
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_ANNOTATION_TARGET
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_ANNOTATION_TARGET_WITH_USE_SITE_TARGET
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_EXTENSION_FUNCTION_TYPE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_EXTENSION_FUNCTION_TYPE_WARNING
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_GETTER_RETURN_TYPE
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_INVOCATION_KIND
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_LONG_SUFFIX
|
||||
@@ -854,7 +855,14 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
|
||||
"Opt-in requirement marker annotation on override makes no sense without the same marker on base declaration"
|
||||
)
|
||||
map.put(NOT_A_CLASS, "Not a class")
|
||||
map.put(WRONG_EXTENSION_FUNCTION_TYPE, "ExtensionFunctionType is forbidden on a function type without parameters")
|
||||
map.put(
|
||||
WRONG_EXTENSION_FUNCTION_TYPE,
|
||||
"ExtensionFunctionType is forbidden on a function type without parameters or on a non-function type"
|
||||
)
|
||||
map.put(
|
||||
WRONG_EXTENSION_FUNCTION_TYPE_WARNING,
|
||||
"ExtensionFunctionType makes no sense on a non-function type. It will be an error in a future release."
|
||||
)
|
||||
|
||||
// Exposed visibility group // #
|
||||
map.put(
|
||||
|
||||
Reference in New Issue
Block a user