From d127162a6d613f41301183e756dfcc00906b28bd Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 31 Jul 2015 18:19:54 +0300 Subject: [PATCH] Removed LOCAL_ENUM_NOT_ALLOWED --- .../jetbrains/kotlin/diagnostics/Errors.java | 1 - .../rendering/DefaultErrorMessages.java | 1 - .../kotlin/resolve/DeclarationsChecker.java | 5 ---- .../diagnostics/tests/enum/localEnums.kt | 10 +++---- .../descriptors/annotations/KotlinTarget.kt | 27 ++++++++++++------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 298b44fbb41..b02ba82678d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -197,7 +197,6 @@ public interface Errors { DiagnosticFactory0 TYPE_PARAMETERS_IN_ENUM = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 ENUM_ENTRY_SHOULD_BE_INITIALIZED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME); DiagnosticFactory1 ENUM_ENTRY_ILLEGAL_TYPE = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 LOCAL_ENUM_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME); DiagnosticFactory2 ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER = DiagnosticFactory2.create(WARNING, DECLARATION_NAME); DiagnosticFactory1 ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR = DiagnosticFactory1.create(WARNING, DELEGATOR_SUPER_CALL); DiagnosticFactory1 ENUM_ENTRY_AFTER_ENUM_MEMBER = DiagnosticFactory1.create(WARNING, DECLARATION_NAME); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index b8e937ddc20..f75372ea844 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -268,7 +268,6 @@ public class DefaultErrorMessages { MAP.put(DEPRECATED_SYMBOL_WITH_MESSAGE, "''{0}'' is deprecated. {1}", DEPRECATION_RENDERER, STRING); MAP.put(LOCAL_OBJECT_NOT_ALLOWED, "Named object ''{0}'' is a singleton and cannot be local. Try to use anonymous object instead", NAME); - MAP.put(LOCAL_ENUM_NOT_ALLOWED, "Enum class ''{0}'' cannot be local", NAME); MAP.put(ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER, "Enum entry ''{0}'' should have a correct delimiter ''{1}'' after it", NAME, STRING); MAP.put(ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR, "Enum entry ''{0}'' uses deprecated super constructor syntax, use ENTRY(arguments) instead", NAME); MAP.put(ENUM_ENTRY_AFTER_ENUM_MEMBER, "Enum entry ''{0}'' is not allowed after a member", NAME); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index b56a0ec52d1..b2cd23de973 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -238,11 +238,6 @@ public class DeclarationsChecker { checkConstructorInTrait(aClass); } - else if (aClass.isEnum()) { - if (aClass.isLocal()) { - trace.report(LOCAL_ENUM_NOT_ALLOWED.on(aClass, classDescriptor)); - } - } else if (classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) { checkAnnotationClassWithBody(aClass); checkValOnAnnotationParameter(aClass); diff --git a/compiler/testData/diagnostics/tests/enum/localEnums.kt b/compiler/testData/diagnostics/tests/enum/localEnums.kt index dd5f20fd7d9..e786e0a83ef 100644 --- a/compiler/testData/diagnostics/tests/enum/localEnums.kt +++ b/compiler/testData/diagnostics/tests/enum/localEnums.kt @@ -1,20 +1,20 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE fun foo() { - enum class A { + enum class A { FOO, BAR } val foo = A.FOO val b = object { - enum class B {} + enum class B {} } class C { - enum class D {} + enum class D {} } val f = { - enum class E {} + enum class E {} } - enum class {} + enum class {} } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt index 90549ba3f6c..c13f49f849e 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/KotlinTarget.kt @@ -81,18 +81,25 @@ public enum class KotlinTarget(val description: String, val isDefault: Boolean = public fun classActualTargets(descriptor: ClassDescriptor): List = when (descriptor.kind) { ClassKind.ANNOTATION_CLASS -> listOf(ANNOTATION_CLASS, CLASSIFIER) - ClassKind.CLASS -> if (descriptor.isInner) { - listOf(INNER_CLASS, CLASSIFIER) - } - else if (DescriptorUtils.isLocal(descriptor)) { - listOf(LOCAL_CLASS, CLASSIFIER) - } - else { - listOf(CLASS, CLASSIFIER) - } + ClassKind.CLASS -> + if (descriptor.isInner) { + listOf(INNER_CLASS, CLASSIFIER) + } + else if (DescriptorUtils.isLocal(descriptor)) { + listOf(LOCAL_CLASS, CLASSIFIER) + } + else { + listOf(CLASS, CLASSIFIER) + } ClassKind.OBJECT -> listOf(OBJECT, CLASSIFIER) ClassKind.INTERFACE -> listOf(INTERFACE, CLASSIFIER) - ClassKind.ENUM_CLASS -> listOf(ENUM_CLASS, CLASSIFIER) + ClassKind.ENUM_CLASS -> + if (DescriptorUtils.isLocal(descriptor)) { + listOf(LOCAL_CLASS, CLASSIFIER) + } + else { + listOf(ENUM_CLASS, CLASSIFIER) + } ClassKind.ENUM_ENTRY -> listOf(ENUM_ENTRY, PROPERTY, FIELD) } }