From 0f1e6ba8bef2604bcc2e621dd255df30d6f539d6 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 28 Jan 2016 16:45:39 +0300 Subject: [PATCH] Refactoring: noTypeCheckingErrorsInExpression introduced --- .../types/expressions/ControlStructureTypingUtils.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java index 4232fc198a5..2bba4529916 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingUtils.java @@ -448,7 +448,7 @@ public class ControlStructureTypingUtils { KtExpression expression = (KtExpression) call.getCallElement(); if (status.hasOnlyErrorsDerivedFrom(EXPECTED_TYPE_POSITION) || status.hasConflictingConstraints() || status.hasTypeInferenceIncorporationError()) { // todo after KT-... remove this line - if (Boolean.TRUE != expression.accept(checkTypeVisitor, new CheckTypeContext(context.trace, data.expectedType))) { + if (noTypeCheckingErrorsInExpression(expression, context.trace, data.expectedType)) { KtExpression calleeExpression = call.getCalleeExpression(); if (calleeExpression instanceof KtWhenExpression || calleeExpression instanceof KtIfExpression) { if (status.hasConflictingConstraints() || status.hasTypeInferenceIncorporationError()) { @@ -463,6 +463,14 @@ public class ControlStructureTypingUtils { logError("Expression: " + (parentDeclaration != null ? parentDeclaration.getText() : expression.getText()) + "\nConstraint system status: \n" + ConstraintsUtil.getDebugMessageForStatus(status)); } + + private boolean noTypeCheckingErrorsInExpression( + KtExpression expression, + @NotNull BindingTrace trace, + @NotNull KotlinType expectedType + ) { + return Boolean.TRUE != expression.accept(checkTypeVisitor, new CheckTypeContext(trace, expectedType)); + } }; }