Added parameter "isStatement" for analyzeInContext and used it in UsePropertyAccessSyntaxIntention
This commit is contained in:
@@ -35,10 +35,11 @@ public fun JetExpression.computeTypeInfoInContext(
|
||||
trace: BindingTrace = BindingTraceContext(),
|
||||
dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY,
|
||||
expectedType: JetType = TypeUtils.NO_EXPECTED_TYPE,
|
||||
module: ModuleDescriptor = scope.getModule()
|
||||
module: ModuleDescriptor = scope.getModule(),
|
||||
isStatement: Boolean = false
|
||||
): JetTypeInfo {
|
||||
val expressionTypingServices = createContainerForMacros(getProject(), module).expressionTypingServices
|
||||
return expressionTypingServices.getTypeInfo(scope, this, expectedType, dataFlowInfo, trace)
|
||||
return expressionTypingServices.getTypeInfo(scope, this, expectedType, dataFlowInfo, trace, isStatement)
|
||||
}
|
||||
|
||||
public fun JetExpression.analyzeInContext(
|
||||
@@ -46,9 +47,10 @@ public fun JetExpression.analyzeInContext(
|
||||
trace: BindingTrace = BindingTraceContext(),
|
||||
dataFlowInfo: DataFlowInfo = DataFlowInfo.EMPTY,
|
||||
expectedType: JetType = TypeUtils.NO_EXPECTED_TYPE,
|
||||
module: ModuleDescriptor = scope.getModule()
|
||||
module: ModuleDescriptor = scope.getModule(),
|
||||
isStatement: Boolean = false
|
||||
): BindingContext {
|
||||
computeTypeInfoInContext(scope, trace, dataFlowInfo, expectedType, module)
|
||||
computeTypeInfoInContext(scope, trace, dataFlowInfo, expectedType, module, isStatement)
|
||||
return trace.getBindingContext()
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -86,12 +86,13 @@ public class ExpressionTypingServices {
|
||||
@NotNull JetExpression expression,
|
||||
@NotNull JetType expectedType,
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull BindingTrace trace
|
||||
@NotNull BindingTrace trace,
|
||||
boolean isStatement
|
||||
) {
|
||||
ExpressionTypingContext context = ExpressionTypingContext.newContext(
|
||||
trace, scope, dataFlowInfo, expectedType
|
||||
);
|
||||
return expressionTypingFacade.getTypeInfo(expression, context);
|
||||
return expressionTypingFacade.getTypeInfo(expression, context, isStatement);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -107,7 +108,7 @@ public class ExpressionTypingServices {
|
||||
@NotNull DataFlowInfo dataFlowInfo,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
return getTypeInfo(scope, expression, expectedType, dataFlowInfo, trace).getType();
|
||||
return getTypeInfo(scope, expression, expectedType, dataFlowInfo, trace, false).getType();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
@@ -98,8 +98,8 @@ class UsePropertyAccessSyntaxIntention : JetSelfTargetingOffsetIndependentIntent
|
||||
val callExpressionCopy = ((qualifiedExpressionCopy as? JetQualifiedExpression)?.selectorExpression ?: qualifiedExpressionCopy) as JetCallExpression
|
||||
val newExpression = applyTo(callExpressionCopy, property.name)
|
||||
val bindingTrace = DelegatingBindingTrace(bindingContext, "Temporary trace")
|
||||
val newBindingContext = newExpression.analyzeInContext(resolutionScope, bindingTrace, dataFlowInfo, expectedType, moduleDescriptor)
|
||||
if (newBindingContext.diagnostics.any { it.severity == Severity.ERROR && it.factory != Errors.ASSIGNMENT_IN_EXPRESSION_CONTEXT }) return null
|
||||
val newBindingContext = newExpression.analyzeInContext(resolutionScope, bindingTrace, dataFlowInfo, expectedType, moduleDescriptor, isStatement = true)
|
||||
if (newBindingContext.diagnostics.any { it.severity == Severity.ERROR }) return null
|
||||
}
|
||||
|
||||
return property.name
|
||||
|
||||
+2
-1
@@ -747,7 +747,8 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
|
||||
new BindingTraceContext(),
|
||||
DataFlowInfo.EMPTY,
|
||||
TypeUtils.NO_EXPECTED_TYPE,
|
||||
DescriptorUtils.getContainingModule(scope.getContainingDeclaration()));
|
||||
DescriptorUtils.getContainingModule(scope.getContainingDeclaration()),
|
||||
false);
|
||||
if (newContext.get(BindingContext.AMBIGUOUS_LABEL_TARGET, labelExpr) != null) {
|
||||
result.putValue(
|
||||
originalExpr,
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ public class KotlinIntroduceVariableHandler extends KotlinIntroduceHandlerBase {
|
||||
|
||||
ObservableBindingTrace bindingTrace = new ObservableBindingTrace(new BindingTraceContext());
|
||||
JetType typeNoExpectedType = AnalyzerPackage.computeTypeInfoInContext(
|
||||
expression, scope, bindingTrace, dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE, analysisResult.getModuleDescriptor()
|
||||
expression, scope, bindingTrace, dataFlowInfo, TypeUtils.NO_EXPECTED_TYPE, analysisResult.getModuleDescriptor(), false
|
||||
).getType();
|
||||
if (expressionType != null && typeNoExpectedType != null && !JetTypeChecker.DEFAULT.equalTypes(expressionType,
|
||||
typeNoExpectedType)) {
|
||||
|
||||
Reference in New Issue
Block a user