From bd73916d99fa34d2bf507447fbea221ad362d250 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 23 May 2017 16:36:12 +0300 Subject: [PATCH] Minor cleanup --- .../kotlin/idea/quickfix/ExclExclCallFixes.kt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt index c14edb393ea..3767007a3d3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/ExclExclCallFixes.kt @@ -159,19 +159,18 @@ object SmartCastImpossibleExclExclFixFactory: KotlinSingleIntentionActionFactory object MissingIteratorExclExclFixFactory : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { - val element = diagnostic.psiElement - if (element !is KtExpression) return null - + val element = diagnostic.psiElement as? KtExpression ?: return null + val analyze = element.analyze(BodyResolveMode.PARTIAL) val type = analyze.getType(element) if (type == null || !TypeUtils.isNullableType(type)) return null val descriptor = type.constructor.declarationDescriptor - fun hasIteratorFunction(descriptor: ClassifierDescriptor?) : Boolean { - if (descriptor !is ClassDescriptor) return false + fun hasIteratorFunction(classifierDescriptor: ClassifierDescriptor?) : Boolean { + if (classifierDescriptor !is ClassDescriptor) return false - val memberScope = descriptor.unsubstitutedMemberScope + val memberScope = classifierDescriptor.unsubstitutedMemberScope val functions = memberScope.getContributedFunctions(OperatorNameConventions.ITERATOR, NoLookupLocation.FROM_IDE) return functions.any { it.isValidOperator() }