From ce02d822f76bacc506b7a075eab51f2b4ed11905 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 1 Sep 2015 00:20:35 +0300 Subject: [PATCH] More safe --- .../ConflictingExtensionPropertyInspection.kt | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt index 126fb6f5cdb..a8858a2be58 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/ConflictingExtensionPropertyInspection.kt @@ -63,34 +63,34 @@ public class ConflictingExtensionPropertyInspection : AbstractKotlinInspection() if (property.receiverTypeReference != null) { val nameElement = property.nameIdentifier ?: return - val propertyDescriptor = property.resolveToDescriptor() as PropertyDescriptor - val conflictingExtension = conflictingSyntheticExtension(propertyDescriptor, fileScope) - if (conflictingExtension != null) { - // don't report on hidden declarations - if (propertyDescriptor.isAnnotatedAsHidden()) return + val propertyDescriptor = property.resolveToDescriptor() as? PropertyDescriptor ?: return - val fixes = if (isSameAsSynthetic(property, conflictingExtension)) { - val fix1 = IntentionWrapper(DeleteRedundantExtensionAction(property), file) - // don't add the second fix when on the fly to allow code cleanup - val fix2 = if (isOnTheFly) - object : IntentionWrapper(MarkHiddenAndDeprecatedAction(property), file), LowPriorityAction {} - else - null - listOf(fix1, fix2).filterNotNull().toTypedArray() - } - else { - emptyArray() - } + val conflictingExtension = conflictingSyntheticExtension(propertyDescriptor, fileScope) ?: return - val problemDescriptor = holder.manager.createProblemDescriptor( - nameElement, - "This property conflicts with synthetic extension and should be removed to avoid breaking code by future changes in the compiler", - true, - fixes, - ProblemHighlightType.GENERIC_ERROR_OR_WARNING - ) - holder.registerProblem(problemDescriptor) + // don't report on hidden declarations + if (propertyDescriptor.isAnnotatedAsHidden()) return + + val fixes = if (isSameAsSynthetic(property, conflictingExtension)) { + val fix1 = IntentionWrapper(DeleteRedundantExtensionAction(property), file) + // don't add the second fix when on the fly to allow code cleanup + val fix2 = if (isOnTheFly) + object : IntentionWrapper(MarkHiddenAndDeprecatedAction(property), file), LowPriorityAction {} + else + null + listOf(fix1, fix2).filterNotNull().toTypedArray() } + else { + emptyArray() + } + + val problemDescriptor = holder.manager.createProblemDescriptor( + nameElement, + "This property conflicts with synthetic extension and should be removed to avoid breaking code by future changes in the compiler", + true, + fixes, + ProblemHighlightType.GENERIC_ERROR_OR_WARNING + ) + holder.registerProblem(problemDescriptor) } } }