FIR opt-in: rename(s) in checker(s)

This commit is contained in:
Mikhail Glukhikh
2021-09-02 16:27:26 +03:00
committed by TeamCityServer
parent 42abc4a3af
commit 8bb16d8e7a
2 changed files with 6 additions and 6 deletions
@@ -25,10 +25,10 @@ object FirOptInAnnotationCallChecker : FirAnnotationCallChecker() {
override fun check(expression: FirAnnotationCall, context: CheckerContext, reporter: DiagnosticReporter) { override fun check(expression: FirAnnotationCall, context: CheckerContext, reporter: DiagnosticReporter) {
val lookupTag = expression.annotationTypeRef.coneTypeSafe<ConeClassLikeType>()?.lookupTag ?: return val lookupTag = expression.annotationTypeRef.coneTypeSafe<ConeClassLikeType>()?.lookupTag ?: return
val classId = lookupTag.classId val classId = lookupTag.classId
val isMarker = classId == OptInNames.REQUIRES_OPT_IN_CLASS_ID val isRequiresOptIn = classId == OptInNames.REQUIRES_OPT_IN_CLASS_ID
val isOptIn = classId == OptInNames.OPT_IN_CLASS_ID val isOptIn = classId == OptInNames.OPT_IN_CLASS_ID
if (isMarker || isOptIn) { if (isRequiresOptIn || isOptIn) {
checkUsageOfKotlinExperimentalOrUseExperimental(expression.source, context, reporter) checkOptInIsEnabled(expression.source, context, reporter)
if (isOptIn) { if (isOptIn) {
val arguments = expression.arguments val arguments = expression.arguments
if (arguments.isEmpty()) { if (arguments.isEmpty()) {
@@ -52,7 +52,7 @@ object FirOptInAnnotationCallChecker : FirAnnotationCallChecker() {
} }
} }
private fun checkUsageOfKotlinExperimentalOrUseExperimental( private fun checkOptInIsEnabled(
element: FirSourceElement?, element: FirSourceElement?,
context: CheckerContext, context: CheckerContext,
reporter: DiagnosticReporter reporter: DiagnosticReporter
@@ -221,10 +221,10 @@ object FirOptInUsageBaseChecker {
} }
private fun FirAnnotationContainer.isExperimentalityAcceptable(annotationClassId: ClassId): Boolean { private fun FirAnnotationContainer.isExperimentalityAcceptable(annotationClassId: ClassId): Boolean {
return getAnnotationByClassId(annotationClassId) != null || isAnnotatedWithUseExperimentalOf(annotationClassId) return getAnnotationByClassId(annotationClassId) != null || isAnnotatedWithOptIn(annotationClassId)
} }
private fun FirAnnotationContainer.isAnnotatedWithUseExperimentalOf(annotationClassId: ClassId): Boolean { private fun FirAnnotationContainer.isAnnotatedWithOptIn(annotationClassId: ClassId): Boolean {
for (annotation in annotations) { for (annotation in annotations) {
val coneType = annotation.annotationTypeRef.coneType as? ConeClassLikeType val coneType = annotation.annotationTypeRef.coneType as? ConeClassLikeType
if (coneType?.lookupTag?.classId != OptInNames.OPT_IN_CLASS_ID) { if (coneType?.lookupTag?.classId != OptInNames.OPT_IN_CLASS_ID) {