diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index 74d0e4efcc3..271093e6371 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -241,7 +241,7 @@ public class JetTypeInferrer { expectedReturnType = NO_EXPECTED_TYPE; } JetScope functionInnerScope = FunctionDescriptorUtil.getFunctionInnerScope(outerScope, functionDescriptor, trace); - checkFunctionReturnType(functionInnerScope, function, expectedReturnType, dataFlowInfo, CoercionStrategy.NO_COERCION); + checkFunctionReturnType(functionInnerScope, function, expectedReturnType, dataFlowInfo); // Map typeMap = collectReturnedExpressionsWithTypes(outerScope, function, functionDescriptor, expectedReturnType); // if (typeMap.isEmpty()) { // return; // The function returns Nothing @@ -276,10 +276,10 @@ public class JetTypeInferrer { } public void checkFunctionReturnType(JetScope functionInnerScope, JetDeclarationWithBody function, @NotNull final JetType expectedReturnType) { - checkFunctionReturnType(functionInnerScope, function, expectedReturnType, DataFlowInfo.getEmpty(), CoercionStrategy.NO_COERCION); + checkFunctionReturnType(functionInnerScope, function, expectedReturnType, DataFlowInfo.getEmpty()); } - private void checkFunctionReturnType(JetScope functionInnerScope, JetDeclarationWithBody function, @NotNull final JetType expectedReturnType, @NotNull DataFlowInfo dataFlowInfo, CoercionStrategy coercionForLastExpression) { + private void checkFunctionReturnType(JetScope functionInnerScope, JetDeclarationWithBody function, @NotNull final JetType expectedReturnType, @NotNull DataFlowInfo dataFlowInfo) { JetExpression bodyExpression = function.getBodyExpression(); assert bodyExpression != null; @@ -935,7 +935,7 @@ public class JetTypeInferrer { JetTypeReference returnTypeRef = functionLiteral.getReturnTypeRef(); if (returnTypeRef != null) { returnType = context.typeResolver.resolveType(context.scope, returnTypeRef); - context.services.checkFunctionReturnType(functionInnerScope, expression, returnType, context.dataFlowInfo, CoercionStrategy.COERCION_TO_UNIT); + context.services.checkFunctionReturnType(functionInnerScope, expression, returnType, context.dataFlowInfo); } else { if (functionTypeExpected) { diff --git a/idea/testData/checker/FunctionReturnTypes.jet b/idea/testData/checker/FunctionReturnTypes.jet index a541589263a..d7e950b69db 100644 --- a/idea/testData/checker/FunctionReturnTypes.jet +++ b/idea/testData/checker/FunctionReturnTypes.jet @@ -115,20 +115,6 @@ fun blockReturnValueTypeMatch() : Int { fun blockNoReturnIfValDeclaration(): Int { val x = 1 } -fun blockNoReturnIfEmptyIf(): Int { - if (1 < 2) {} else {} -} -fun blockNoReturnIfUnitInOneBranch(): Int { - if (1 < 2) { - return 1 - } else { - if (3 < 4) { - } else { - return 2 - } - } -} - val a = return 1 class A() {