From 1a93c276f6e92ea6a9dfae7cc7606fb02bbf1be7 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Wed, 18 May 2016 12:27:27 +0300 Subject: [PATCH] Minor. Apply 'Simplify if' --- .../types/expressions/ControlStructureTypingVisitor.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java index df0c33c6063..32c639cd7d8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ControlStructureTypingVisitor.java @@ -607,16 +607,14 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { context.trace.report(NOT_A_RETURN_LABEL.on(expression, expression.getLabelName())); } } + if (returnedExpression != null) { facade.getTypeInfo(returnedExpression, context.replaceExpectedType(expectedType).replaceScope(context.scope) .replaceContextDependency(INDEPENDENT)); } else { - if (expectedType != null && - !noExpectedType(expectedType) && - !KotlinBuiltIns.isUnit(expectedType) && - !isDontCarePlaceholder(expectedType)) // for lambda with implicit return type Unit - { + // for lambda with implicit return type Unit + if (!noExpectedType(expectedType) && !KotlinBuiltIns.isUnit(expectedType) && !isDontCarePlaceholder(expectedType)) { context.trace.report(RETURN_TYPE_MISMATCH.on(expression, expectedType)); } }