diff --git a/compiler/testData/diagnostics/tests/functionLiterals/kt3343.kt b/compiler/testData/diagnostics/tests/functionLiterals/kt3343.kt new file mode 100644 index 00000000000..aa1a95a8bb2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/kt3343.kt @@ -0,0 +1,25 @@ +// KT-3343 Type mismatch when function literal consists of try-catch with Int returning call, and Unit is expected + +fun main(args : Array) { + "hello world".prt{ + try{ + print(it) + log("we are printing") + } + catch(e : Exception){ + log("Exception") + } + } +} + +fun log(str : String) : Int{ + print("logging $str") + return 0 +} + +fun print(obj: Any) {} + + +fun String.prt(action : (String) -> Unit){ + action(this) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/kt3343.txt b/compiler/testData/diagnostics/tests/functionLiterals/kt3343.txt new file mode 100644 index 00000000000..30a4baa2955 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/kt3343.txt @@ -0,0 +1,6 @@ +package + +public fun log(/*0*/ str: kotlin.String): kotlin.Int +public fun main(/*0*/ args: kotlin.Array): kotlin.Unit +public fun print(/*0*/ obj: kotlin.Any): kotlin.Unit +public fun kotlin.String.prt(/*0*/ action: (kotlin.String) -> kotlin.Unit): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 838d3e47ad4..3184c8c62c0 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -6282,6 +6282,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt3343.kt") + public void testKt3343() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/functionLiterals/kt3343.kt"); + doTest(fileName); + } + @TestMetadata("kt4529.kt") public void testKt4529() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/functionLiterals/kt4529.kt");