Removed LOCAL_ENUM_NOT_ALLOWED

This commit is contained in:
Mikhail Glukhikh
2015-07-31 18:19:54 +03:00
parent a104b2c84c
commit d127162a6d
5 changed files with 22 additions and 22 deletions
@@ -197,7 +197,6 @@ public interface Errors {
DiagnosticFactory0<JetTypeParameterList> TYPE_PARAMETERS_IN_ENUM = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<JetClass, ClassDescriptor> ENUM_ENTRY_SHOULD_BE_INITIALIZED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
DiagnosticFactory1<JetTypeReference, ClassDescriptor> ENUM_ENTRY_ILLEGAL_TYPE = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<JetClass, ClassDescriptor> LOCAL_ENUM_NOT_ALLOWED = DiagnosticFactory1.create(ERROR, DECLARATION_NAME);
DiagnosticFactory2<JetEnumEntry, ClassDescriptor, String> ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER = DiagnosticFactory2.create(WARNING, DECLARATION_NAME);
DiagnosticFactory1<JetEnumEntry, ClassDescriptor> ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR = DiagnosticFactory1.create(WARNING, DELEGATOR_SUPER_CALL);
DiagnosticFactory1<JetEnumEntry, ClassDescriptor> ENUM_ENTRY_AFTER_ENUM_MEMBER = DiagnosticFactory1.create(WARNING, DECLARATION_NAME);
@@ -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);
@@ -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);
+5 -5
View File
@@ -1,20 +1,20 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
fun foo() {
<!LOCAL_ENUM_NOT_ALLOWED!>enum class A<!> {
<!WRONG_MODIFIER_TARGET!>enum<!> class A {
FOO,
BAR
}
val foo = A.FOO
val b = object {
<!LOCAL_ENUM_NOT_ALLOWED!>enum class B<!> {}
<!WRONG_MODIFIER_TARGET!>enum<!> class B {}
}
class C {
<!LOCAL_ENUM_NOT_ALLOWED!>enum class D<!> {}
<!WRONG_MODIFIER_TARGET!>enum<!> class D {}
}
val f = {
<!LOCAL_ENUM_NOT_ALLOWED!>enum class E<!> {}
<!WRONG_MODIFIER_TARGET!>enum<!> class E {}
}
enum class<!SYNTAX!><!> {}
<!WRONG_MODIFIER_TARGET!>enum<!> class<!SYNTAX!><!> {}
}
@@ -81,18 +81,25 @@ public enum class KotlinTarget(val description: String, val isDefault: Boolean =
public fun classActualTargets(descriptor: ClassDescriptor): List<KotlinTarget> = 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)
}
}