[FIR] Fix rendering of SUBCLASS_OPT_IN_INAPPLICABLE
This commit is contained in:
committed by
Space Team
parent
14bdcbfecd
commit
dd0e919860
+16
-4
@@ -54,13 +54,19 @@ object FirOptInAnnotationCallChecker : FirAnnotationCallChecker() {
|
|||||||
val declaration = context.containingDeclarations.lastOrNull() as? FirClass
|
val declaration = context.containingDeclarations.lastOrNull() as? FirClass
|
||||||
if (declaration != null) {
|
if (declaration != null) {
|
||||||
val kind = declaration.classKind
|
val kind = declaration.classKind
|
||||||
|
val classKindRepresentation = kind.representation
|
||||||
if (kind == ClassKind.ENUM_CLASS || kind == ClassKind.OBJECT || kind == ClassKind.ANNOTATION_CLASS) {
|
if (kind == ClassKind.ENUM_CLASS || kind == ClassKind.OBJECT || kind == ClassKind.ANNOTATION_CLASS) {
|
||||||
reporter.reportOn(expression.source, FirErrors.SUBCLASS_OPT_IN_INAPPLICABLE, kind.toString(), context)
|
reporter.reportOn(expression.source, FirErrors.SUBCLASS_OPT_IN_INAPPLICABLE, classKindRepresentation, context)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val modality = declaration.modality()
|
val modality = declaration.modality()
|
||||||
if (modality == Modality.FINAL || modality == Modality.SEALED) {
|
if (modality == Modality.FINAL || modality == Modality.SEALED) {
|
||||||
reporter.reportOn(expression.source, FirErrors.SUBCLASS_OPT_IN_INAPPLICABLE, "$modality $kind", context)
|
reporter.reportOn(
|
||||||
|
expression.source,
|
||||||
|
FirErrors.SUBCLASS_OPT_IN_INAPPLICABLE,
|
||||||
|
"${modality.name.lowercase()} $classKindRepresentation",
|
||||||
|
context,
|
||||||
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (declaration.isFun) {
|
if (declaration.isFun) {
|
||||||
@@ -68,7 +74,7 @@ object FirOptInAnnotationCallChecker : FirAnnotationCallChecker() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (declaration.isLocal) {
|
if (declaration.isLocal) {
|
||||||
reporter.reportOn(expression.source, FirErrors.SUBCLASS_OPT_IN_INAPPLICABLE, "local $kind", context)
|
reporter.reportOn(expression.source, FirErrors.SUBCLASS_OPT_IN_INAPPLICABLE, "local $classKindRepresentation", context)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,10 +83,16 @@ object FirOptInAnnotationCallChecker : FirAnnotationCallChecker() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val ClassKind.representation: String
|
||||||
|
get() = when (this) {
|
||||||
|
ClassKind.ENUM_ENTRY -> "enum entry"
|
||||||
|
else -> codeRepresentation!!
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkOptInIsEnabled(
|
private fun checkOptInIsEnabled(
|
||||||
element: KtSourceElement?,
|
element: KtSourceElement?,
|
||||||
context: CheckerContext,
|
context: CheckerContext,
|
||||||
reporter: DiagnosticReporter
|
reporter: DiagnosticReporter,
|
||||||
) {
|
) {
|
||||||
val languageVersionSettings = context.session.languageVersionSettings
|
val languageVersionSettings = context.session.languageVersionSettings
|
||||||
val optInFqNames = languageVersionSettings.getFlag(AnalysisFlags.optIn)
|
val optInFqNames = languageVersionSettings.getFlag(AnalysisFlags.optIn)
|
||||||
|
|||||||
Reference in New Issue
Block a user