From 6d163a7a8c7d5c66b3228f2ff5919a01c7b650f5 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Fri, 14 Aug 2015 17:10:20 +0300 Subject: [PATCH] Used more specific API --- .../idea/intentions/ConvertToExpressionBodyIntention.kt | 6 +++--- .../kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToExpressionBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToExpressionBodyIntention.kt index 6e355cf8e94..140dcf1086e 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToExpressionBodyIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ConvertToExpressionBodyIntention.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import com.intellij.psi.PsiElement -import org.jetbrains.kotlin.analyzer.analyzeInContext +import org.jetbrains.kotlin.analyzer.computeTypeInContext import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.idea.caches.resolve.analyze @@ -97,8 +97,8 @@ public class ConvertToExpressionBodyIntention : JetSelfTargetingOffsetIndependen val declaredType = (declaration.resolveToDescriptor() as? CallableDescriptor)?.getReturnType() ?: return false val scope = scopeExpression.analyze()[BindingContext.RESOLUTION_SCOPE, scopeExpression] ?: return false - val expressionType = expression.analyzeInContext(scope).getType(expression) ?: return false - return expressionType.isSubtypeOf(declaredType) + val expressionType = expression.computeTypeInContext(scope) + return !expressionType.isError && expressionType.isSubtypeOf(declaredType) } private fun calcValue(declaration: JetDeclarationWithBody): JetExpression? { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt index e857ecb0822..b45c2c3235f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/DeprecatedSymbolUsageFixBase.kt @@ -21,7 +21,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.util.Key import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile -import org.jetbrains.kotlin.analyzer.analyzeInContext +import org.jetbrains.kotlin.analyzer.computeTypeInContext import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor @@ -679,11 +679,11 @@ public abstract class DeprecatedSymbolUsageFixBase( if (usages.isNotEmpty()) { var explicitType: JetType? = null if (valueType != null && !ErrorUtils.containsErrorType(valueType)) { - val valueTypeWithoutExpectedType = value.analyzeInContext( + val valueTypeWithoutExpectedType = value.computeTypeInContext( resolutionScope!!, dataFlowInfo = bindingContext.getDataFlowInfo(expressionToBeReplaced) - ).getType(value) - if (valueTypeWithoutExpectedType == null || ErrorUtils.containsErrorType(valueTypeWithoutExpectedType)) { + ) + if (ErrorUtils.containsErrorType(valueTypeWithoutExpectedType)) { explicitType = valueType } }