diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java index d09f8bd9f44..ebc9b2c9f9f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java @@ -462,7 +462,7 @@ public class ExpressionTypingUtils { @Override public void report(@NotNull Diagnostic diagnostic) { AbstractDiagnosticFactory factory = diagnostic.getFactory(); - if ((factory == TYPE_MISMATCH || factory == CONSTANT_EXPECTED_TYPE_MISMATCH) + if ((factory == TYPE_MISMATCH || factory == CONSTANT_EXPECTED_TYPE_MISMATCH || factory == NULL_FOR_NONNULL_TYPE) && diagnostic.getPsiElement() == expressionToWatch) { mismatchFound[0] = true; } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/returnNull.kt b/compiler/testData/diagnostics/tests/functionLiterals/returnNull.kt new file mode 100644 index 00000000000..8110dc40a3c --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/returnNull.kt @@ -0,0 +1,10 @@ +package m + +trait Element + +fun test(handlers: MapUnit>) { + + handlers.getOrElse("name", { null }) +} + +fun Map.getOrElse(key: K, defaultValue: ()-> V) : V = throw Exception("$key $defaultValue") \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 8acbcaa80ac..4fd94896cba 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -2685,6 +2685,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/functionLiterals/NoDanglingFunctionLiteralForNestedCalls.kt"); } + @TestMetadata("returnNull.kt") + public void testReturnNull() throws Exception { + doTest("compiler/testData/diagnostics/tests/functionLiterals/returnNull.kt"); + } + @TestMetadata("unusedLiteral.kt") public void testUnusedLiteral() throws Exception { doTest("compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt");