From 59e74e79c2e65ef0b9eda878c28b34b9f61ce4a2 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Fri, 23 Nov 2012 16:10:12 +0400 Subject: [PATCH] Test for KT-2619 Remove outdated check in WhenChecker # KT-2619 fixed --- .../org/jetbrains/jet/lang/cfg/WhenChecker.java | 7 +------ compiler/testData/diagnostics/tests/j+k/kt2619.kt | 15 +++++++++++++++ .../jet/checkers/JetDiagnosticsTestGenerated.java | 5 +++++ 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/j+k/kt2619.kt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/WhenChecker.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/WhenChecker.java index 8d71c9f622a..13ab0695c2a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/WhenChecker.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/WhenChecker.java @@ -49,12 +49,7 @@ public final class WhenChecker { ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor; if (classDescriptor.getKind() != ClassKind.ENUM_CLASS || classDescriptor.getModality().isOverridable()) return false; ClassDescriptor classObjectDescriptor = classDescriptor.getClassObjectDescriptor(); - //TODO: workaround for KT-2619 Exception on using java enum in when. - // should provide correct checks for java enums - // may be obsolete once java and kotlin enum work the same way - if (classObjectDescriptor == null) { - return false; - } + assert classObjectDescriptor != null : "Enum classes must have class object."; JetScope memberScope = classObjectDescriptor.getMemberScope(Collections.emptyList()); Collection objectDescriptors = memberScope.getObjectDescriptors(); boolean isExhaust = true; diff --git a/compiler/testData/diagnostics/tests/j+k/kt2619.kt b/compiler/testData/diagnostics/tests/j+k/kt2619.kt new file mode 100644 index 00000000000..06e5651e4cf --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/kt2619.kt @@ -0,0 +1,15 @@ +//FILE: foo.kt +fun main(args: Array) { + val c: Type + when (c) { + + } +} + + + +//FILE: Type.java +public enum Type { + TYPE, + NO_TYPE; +} \ 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 dd17ae05e62..8bb4ef4ef82 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -2237,6 +2237,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/j+k/kt2606.kt"); } + @TestMetadata("kt2619.kt") + public void testKt2619() throws Exception { + doTest("compiler/testData/diagnostics/tests/j+k/kt2619.kt"); + } + @TestMetadata("kt2641.kt") public void testKt2641() throws Exception { doTest("compiler/testData/diagnostics/tests/j+k/kt2641.kt");