From 6cee65d74e60a4c8920898d7441d039bb3da5eea Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 22 Aug 2013 14:43:34 +0400 Subject: [PATCH] A test for nesting implicitly labeled calls The actual error message should be "return not allowed", but due to a bug in label resolution it is "unresolved reference" --- .../functionLiterals/return/AutoLabelsNonLocal.kt | 14 ++++++++++++++ .../jet/checkers/JetDiagnosticsTestGenerated.java | 5 +++++ 2 files changed, 19 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabelsNonLocal.kt diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabelsNonLocal.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabelsNonLocal.kt new file mode 100644 index 00000000000..a13a41fe6f5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabelsNonLocal.kt @@ -0,0 +1,14 @@ +fun f() { + foo {(): Int -> + bar { + (): Int -> + // The actual error message should be "return not allowed", + // but due to a bug in label resolution it is "unresolved reference" + return@foo 1 + } + return@foo 1 + } +} + +fun foo(a: Any) {} +fun bar(a: Any) {} \ 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 4afcba8d7b8..848f8cc9661 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -2437,6 +2437,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabels.kt"); } + @TestMetadata("AutoLabelsNonLocal.kt") + public void testAutoLabelsNonLocal() throws Exception { + doTest("compiler/testData/diagnostics/tests/functionLiterals/return/AutoLabelsNonLocal.kt"); + } + @TestMetadata("ForbiddenNonLocalReturnNoType.kt") public void testForbiddenNonLocalReturnNoType() throws Exception { doTest("compiler/testData/diagnostics/tests/functionLiterals/return/ForbiddenNonLocalReturnNoType.kt");