More uses of partial body resolve

This commit is contained in:
Valentin Kipyatkov
2016-10-30 14:55:18 +03:00
parent 68174470c3
commit 6d3dd5d9b7
11 changed files with 22 additions and 17 deletions
@@ -582,7 +582,7 @@ class ExpectedInfos(
val loopVar = forExpression.loopParameter
val loopVarType = if (loopVar != null && loopVar.typeReference != null)
(resolutionFacade.resolveToDescriptor(loopVar) as VariableDescriptor).type.check { !it.isError }
(bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, loopVar] as VariableDescriptor).type.check { !it.isError }
else
null
@@ -617,7 +617,7 @@ class ExpectedInfos(
private fun calculateForPropertyDelegate(expressionWithType: KtExpression): Collection<ExpectedInfo>? {
val delegate = expressionWithType.parent as? KtPropertyDelegate ?: return null
val propertyDeclaration = delegate.parent as? KtProperty ?: return null
val property = resolutionFacade.resolveToDescriptor(propertyDeclaration) as? PropertyDescriptor ?: return null
val property = bindingContext[BindingContext.DECLARATION_TO_DESCRIPTOR, propertyDeclaration] as? PropertyDescriptor ?: return null
val scope = expressionWithType.getResolutionScope(bindingContext, resolutionFacade)
val propertyOwnerType = property.fuzzyExtensionReceiverType()
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.resolveToDescriptor
import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.typeUtil.isUnit
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
@@ -51,7 +51,7 @@ class KotlinNameSuggestionProvider : NameSuggestionProvider {
this += KotlinNameSuggester.getCamelNames(name!!, validator, name.first().isLowerCase())
}
val callableDescriptor = element.resolveToDescriptor() as CallableDescriptor
val callableDescriptor = element.resolveToDescriptor(BodyResolveMode.PARTIAL) as CallableDescriptor
val type = callableDescriptor.returnType
if (type != null && !type.isUnit() && !KotlinBuiltIns.isPrimitiveType(type)) {
this += KotlinNameSuggester.suggestNamesByType(type, validator)
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorResolver
import org.jetbrains.kotlin.resolve.OverridingUtil
import org.jetbrains.kotlin.resolve.calls.callUtil.getValueArgumentsInParentheses
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
@Suppress("UNCHECKED_CAST")
inline fun <reified T: PsiElement> PsiElement.replaced(newElement: T): T {
@@ -205,7 +206,7 @@ fun KtDeclaration.implicitVisibility(): KtModifierKeywordToken? =
else KtTokens.DEFAULT_VISIBILITY_KEYWORD
}
else if (hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
(resolveToDescriptor() as? CallableMemberDescriptor)
(resolveToDescriptor(BodyResolveMode.PARTIAL) as? CallableMemberDescriptor)
?.overriddenDescriptors
?.let { OverridingUtil.findMaxVisibility(it) }
?.toKeywordToken()