diff --git a/compiler/testData/diagnostics/tests/inference/useFunctionLiteralsToInferType.kt b/compiler/testData/diagnostics/tests/inference/useFunctionLiteralsToInferType.kt new file mode 100644 index 00000000000..9a8a8632d35 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/useFunctionLiteralsToInferType.kt @@ -0,0 +1,16 @@ +package m + +import java.util.HashSet + +// ---------------------------------- +fun testGetOrPut(result : MutableMap>, key: K) { + result.getOrPut(key) { HashSet() } +} + +fun MutableMap.getOrPut(key: K, defaultValue: ()-> V) : V = throw Exception("$key $defaultValue") + +// ---------------------------------- +class Property>(val name: String, val default: () -> T) {} + +fun testProperty() = Property("", { -1.toLong() }) +fun testProperty1() = Property("", { "" }) diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 4fd94896cba..826dd280080 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -3104,6 +3104,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/inference/typeInferenceExpectedTypeMismatch.kt"); } + @TestMetadata("useFunctionLiteralsToInferType.kt") + public void testUseFunctionLiteralsToInferType() throws Exception { + doTest("compiler/testData/diagnostics/tests/inference/useFunctionLiteralsToInferType.kt"); + } + @TestMetadata("compiler/testData/diagnostics/tests/inference/nestedCalls") public static class NestedCalls extends AbstractDiagnosticsTestWithEagerResolve { public void testAllFilesPresentInNestedCalls() throws Exception {