dangerousFlexibleTypeOrNull : minor refactoring

(cherry picked from commit 31e8fe5)
This commit is contained in:
Mikhail Glukhikh
2016-06-20 19:36:42 +03:00
committed by Mikhail Glukhikh
parent 70becfbd86
commit 048b6b60e9
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptorIfAny
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.util.IdeDescriptorRenderers
import org.jetbrains.kotlin.idea.util.application.runWriteAction
@@ -62,8 +63,7 @@ class SpecifyTypeExplicitlyIntention :
if (declaration.containingClassOrObject?.isLocal() ?: false) return null
val context = declaration.analyze(BodyResolveMode.PARTIAL)
val callable = context[BindingContext.DECLARATION_TO_DESCRIPTOR, declaration] as? CallableDescriptor ?: return null
val callable = declaration.resolveToDescriptorIfAny() as? CallableDescriptor ?: return null
if (publicAPIOnly && !callable.visibility.isPublicAPI) return null
val type = callable.returnType ?: return null
if (!type.isFlexibleRecursive()) return null