Enum deprecated syntax detection implemented and integrated into DeclarationsChecker.

A lot of tests was changed to refactor deprecated syntax. Six new tests were added to check deprecated syntax detection.
Diagnostic for "enum entry uses deprecated super constructor": constructor is highlighted
Diagnostic for "enum entry uses deprecated or no delimiter".
One warning removed.
This commit is contained in:
Mikhail Glukhikh
2015-05-08 10:29:51 +03:00
parent 1a312140e9
commit 147bca3d22
74 changed files with 637 additions and 114 deletions
@@ -211,6 +211,8 @@ public interface Errors {
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);
// Companion objects
@@ -428,4 +428,11 @@ public object PositioningStrategies {
return markElement(element.getCalleeExpression() ?: element)
}
}
public val DELEGATOR_SUPER_CALL: PositioningStrategy<JetEnumEntry> = object: PositioningStrategy<JetEnumEntry>() {
override fun mark(element: JetEnumEntry): List<TextRange> {
val specifiers = element.getDelegationSpecifiers()
return markElement(if (specifiers.isEmpty()) element else specifiers[0])
}
}
}
@@ -257,6 +257,8 @@ public class DefaultErrorMessages {
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(DELEGATION_IN_TRAIT, "Interfaces cannot use delegation");
MAP.put(DELEGATION_NOT_TO_TRAIT, "Only interfaces can be delegated to");
MAP.put(UNMET_TRAIT_REQUIREMENT, "Super interface ''{0}'' requires subclasses to extend ''{1}''", NAME, NAME);
@@ -99,6 +99,15 @@ inline public fun PsiElement.getChildrenOfType<reified T: PsiElement>(): Array<T
return PsiTreeUtil.getChildrenOfType(this, javaClass<T>()) ?: array()
}
public fun PsiElement.getNextSiblingIgnoringWhitespace(): PsiElement {
var current = this
do {
current = current.getNextSibling()
}
while (current.getNode().getElementType() == JetTokens.WHITE_SPACE)
return current
}
public fun PsiElement?.isAncestor(element: PsiElement, strict: Boolean = false): Boolean {
return PsiTreeUtil.isAncestor(this, element, strict)
}
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.resolve;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.*;
@@ -26,6 +28,7 @@ import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.lexer.JetModifierKeywordToken;
import org.jetbrains.kotlin.lexer.JetTokens;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.SubstitutionUtils;
import org.jetbrains.kotlin.types.TypeConstructor;
@@ -206,6 +209,7 @@ public class DeclarationsChecker {
DeclarationDescriptor containingDeclaration = typeParameterDescriptor.getContainingDeclaration();
assert containingDeclaration instanceof ClassDescriptor : containingDeclaration;
JetClassOrObject psiElement = (JetClassOrObject) DescriptorToSourceUtils.getSourceFromDescriptor(classDescriptor);
assert psiElement != null;
JetDelegationSpecifierList delegationSpecifierList = psiElement.getDelegationSpecifierList();
assert delegationSpecifierList != null;
// trace.getErrorHandler().genericError(delegationSpecifierList.getNode(), "Type parameter " + typeParameterDescriptor.getName() + " of " + containingDeclaration.getName() + " has inconsistent values: " + conflictingTypes);
@@ -535,11 +539,65 @@ public class DeclarationsChecker {
}
}
// Temporary
// Returns true if deprecated constructor is in use, like
// ENTRY: Enum(arguments) instead of
// ENTRY(arguments)
public static boolean enumEntryUsesDeprecatedSuperConstructor(@NotNull JetEnumEntry enumEntry) {
JetInitializerList initializerList = enumEntry.getInitializerList();
if (initializerList == null) return false;
JetTypeReference typeReference = initializerList.getInitializers().get(0).getTypeReference();
if (typeReference == null) return false;
JetUserType userType = (JetUserType) typeReference.getTypeElement();
if (userType == null || userType.getReferenceExpression() instanceof JetEnumEntrySuperclassReferenceExpression) return false;
return true;
}
// Temporary
// Returns comma if it's an enum entry without following comma (entry is not last in enum),
// or semicolon if it's an enum entry without following semicolon, may be after comma (entry is last in enum),
// or empty string if an enum entry has the necessary following delimiter
@NotNull
private static String enumEntryExpectedDelimiter(@NotNull JetEnumEntry enumEntry) {
PsiElement next = enumEntry.getNextSibling();
while (next != null) {
if (next instanceof JetDeclaration) break;
next = next.getNextSibling();
}
JetDeclaration nextDeclaration = (JetDeclaration) next;
next = PsiUtilPackage.getNextSiblingIgnoringWhitespace(enumEntry);
IElementType nextType = next.getNode().getElementType();
if (nextDeclaration instanceof JetEnumEntry) {
// Not last
return nextType != JetTokens.COMMA ? "," : "";
}
else {
// Last: after it we can have semicolon, just closing brace, or comma followed by semicolon / closing brace
if (nextType == JetTokens.COMMA) {
next = PsiUtilPackage.getNextSiblingIgnoringWhitespace(next);
nextType = next.getNode().getElementType();
}
return nextType != JetTokens.SEMICOLON && nextType != JetTokens.RBRACE ? ";" : "";
}
}
public static boolean enumEntryUsesDeprecatedOrNoDelimiter(@NotNull JetEnumEntry enumEntry) {
return !enumEntryExpectedDelimiter(enumEntry).isEmpty();
}
private void checkEnumEntry(@NotNull JetEnumEntry enumEntry, @NotNull ClassDescriptor classDescriptor) {
DeclarationDescriptor declaration = classDescriptor.getContainingDeclaration();
assert DescriptorUtils.isEnumClass(declaration) : "Enum entry should be declared in enum class: " + classDescriptor;
ClassDescriptor enumClass = (ClassDescriptor) declaration;
if (enumEntryUsesDeprecatedSuperConstructor(enumEntry)) {
trace.report(Errors.ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR.on(enumEntry, classDescriptor));
}
String neededDelimiter = enumEntryExpectedDelimiter(enumEntry);
if (!neededDelimiter.isEmpty()) {
trace.report(Errors.ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER.on(enumEntry, classDescriptor, neededDelimiter));
}
List<JetDelegationSpecifier> delegationSpecifiers = enumEntry.getDelegationSpecifiers();
ConstructorDescriptor constructor = enumClass.getUnsubstitutedPrimaryConstructor();
if ((constructor == null || !constructor.getValueParameters().isEmpty()) && delegationSpecifiers.isEmpty()) {
@@ -1,6 +1,6 @@
enum class A {
ONE
TWO
ONE,
TWO;
fun invoke(i: Int) = i
}
@@ -1,5 +1,5 @@
enum class A {
ONE
ONE,
TWO
}
@@ -1,8 +1,8 @@
import A.ONE
enum class A {
ONE
TWO
ONE,
TWO;
fun invoke(i: Int) = i
}
@@ -1,7 +1,7 @@
import A.ONE
enum class A {
ONE
ONE,
TWO
}
@@ -2,7 +2,7 @@ package a
enum class C {
E1 E2 E3 {
E1, E2, E3 {
object O_O
fun b() {
@@ -10,7 +10,7 @@ enum class C {
}
class G
}
},
E4 {
fun c() {
@@ -22,7 +22,7 @@ enum class C {
//TODO: this is a bug
this.<!UNRESOLVED_REFERENCE!>A<!>()
}
}
};
class A
inner class B
@@ -71,11 +71,11 @@ fun t1() {
enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
},
TALKING {
override fun signal() = ProtocolState.WAITING
}
};
abstract fun signal() : ProtocolState
}
@@ -3,9 +3,9 @@
package kt1185
enum class Direction {
NORTH
SOUTH
WEST
NORTH,
SOUTH,
WEST,
EAST
}
@@ -16,9 +16,9 @@ class A {
}
enum class Color(val rgb : Int) {
RED : Color(0xFF0000)
GREEN : Color(0x00FF00)
BLUE : Color(0x0000FF)
RED(0xFF0000),
GREEN(0x00FF00),
BLUE(0x0000FF)
}
fun foo(d: Direction) = when(d) { //no 'else' should be requested
@@ -4,13 +4,13 @@
package kt1193
enum class MyEnum(val i: Int) {
A : MyEnum(12)
A(12),
<!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>B<!> //no error
}
open class A(x: Int = 1)
enum class MyOtherEnum(val i: Int) {
X : <!ENUM_ENTRY_ILLEGAL_TYPE!>A<!>(3)
Y : <!ENUM_ENTRY_ILLEGAL_TYPE!>A<!>()
Z : <!ENUM_ENTRY_ILLEGAL_TYPE!>A<!>(3) {}
X : <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!><!ENUM_ENTRY_ILLEGAL_TYPE!>A<!>(3)<!>,
Y : <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!><!ENUM_ENTRY_ILLEGAL_TYPE!>A<!>()<!>,
Z : <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!><!ENUM_ENTRY_ILLEGAL_TYPE!>A<!>(3)<!> {}
}
@@ -1,6 +1,6 @@
enum class <!CONFLICTING_JVM_DECLARATIONS, CONFLICTING_JVM_DECLARATIONS!>A<!> {
A1
A2
A1,
A2;
<!CONFLICTING_JVM_DECLARATIONS!>fun valueOf(s: String): A<!> = valueOf(s)
@@ -2,7 +2,7 @@ enum class E : T {
ENTRY {
override fun f() {
}
}
};
abstract override fun f()
}
@@ -1,5 +1,5 @@
enum class E {
ENTRY
ENTRY;
companion object {
fun entry() = ENTRY
@@ -1,5 +1,5 @@
enum class E {
ENTRY
ENTRY;
private companion object
}
@@ -1,8 +1,8 @@
enum class E {
FIRST
FIRST,
SECOND {
class A
}
};
}
val foo: Any.() -> Unit = {}
@@ -1,5 +1,5 @@
enum class E {
E1
E1,
E2
}
@@ -0,0 +1,6 @@
enum class MyEnum {
A,
<!ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER!>B<!>,
val z = 42
}
@@ -0,0 +1,38 @@
package
internal final enum class MyEnum : kotlin.Enum<MyEnum> {
public enum entry A : MyEnum {
private constructor A()
internal final override /*1*/ /*fake_override*/ val z: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry B : MyEnum {
private constructor B()
internal final override /*1*/ /*fake_override*/ val z: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
private constructor MyEnum()
internal final val z: kotlin.Int = 42
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum>
}
@@ -1,11 +1,11 @@
enum class E {
FIRST
FIRST,
SECOND {
<!COMPANION_OBJECT_NOT_ALLOWED!>companion<!> object {
fun foo() = 42
}
}
};
}
fun f() = E.SECOND.<!UNRESOLVED_REFERENCE!>foo<!>()
@@ -2,11 +2,11 @@ enum class EnumClass {
E1 {
override fun foo() = 1
override val bar: String = "a"
}
},
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>E2<!> {
}
};
abstract fun foo(): Int
abstract val bar: String
@@ -5,7 +5,7 @@ interface T1 {
enum class EnumImplementingTraitWithFun: T1 {
E1 {
override fun foo() {}
}
},
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>E2<!>
}
@@ -16,6 +16,6 @@ interface T2 {
enum class EnumImplementingTraitWithVal: T2 {
E1 {
override val bar = 1
}
},
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>E2<!>
}
@@ -0,0 +1,3 @@
enum class MyEnum {
A, B, <!ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER!>C<!> D, <!ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER!>E<!> F
}
@@ -0,0 +1,75 @@
package
internal final enum class MyEnum : kotlin.Enum<MyEnum> {
public enum entry A : MyEnum {
private constructor A()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry B : MyEnum {
private constructor B()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry C : MyEnum {
private constructor C()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry D : MyEnum {
private constructor D()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry E : MyEnum {
private constructor E()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry F : MyEnum {
private constructor F()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
private constructor MyEnum()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum>
}
@@ -0,0 +1,4 @@
enum class MyEnum {
<!ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER!>A<!>
B
}
@@ -0,0 +1,35 @@
package
internal final enum class MyEnum : kotlin.Enum<MyEnum> {
public enum entry A : MyEnum {
private constructor A()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry B : MyEnum {
private constructor B()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
private constructor MyEnum()
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum>
}
@@ -0,0 +1,6 @@
enum class MyEnum {
A,
<!ENUM_ENTRY_USES_DEPRECATED_OR_NO_DELIMITER!>B<!>
val z = 42
}
@@ -0,0 +1,38 @@
package
internal final enum class MyEnum : kotlin.Enum<MyEnum> {
public enum entry A : MyEnum {
private constructor A()
internal final override /*1*/ /*fake_override*/ val z: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry B : MyEnum {
private constructor B()
internal final override /*1*/ /*fake_override*/ val z: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
private constructor MyEnum()
internal final val z: kotlin.Int = 42
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum>
}
@@ -0,0 +1,6 @@
enum class MyEnum(val myArg: Int) {
FIRST(1),
SECOND: <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!>MyEnum(2)<!>,
THIRD(3),
FOURTH(4)
}
@@ -0,0 +1,60 @@
package
internal final enum class MyEnum : kotlin.Enum<MyEnum> {
public enum entry FIRST : MyEnum {
private constructor FIRST()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry SECOND : MyEnum {
private constructor SECOND()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry THIRD : MyEnum {
private constructor THIRD()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry FOURTH : MyEnum {
private constructor FOURTH()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
private constructor MyEnum(/*0*/ myArg: kotlin.Int)
internal final val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum>
}
@@ -0,0 +1,6 @@
enum class MyEnum(val myArg: Int) {
FIRST(1),
SECOND: <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!>MyEnum(myArg = 2)<!>,
THIRD(3),
FOURTH(4)
}
@@ -0,0 +1,60 @@
package
internal final enum class MyEnum : kotlin.Enum<MyEnum> {
public enum entry FIRST : MyEnum {
private constructor FIRST()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry SECOND : MyEnum {
private constructor SECOND()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry THIRD : MyEnum {
private constructor THIRD()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry FOURTH : MyEnum {
private constructor FOURTH()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
private constructor MyEnum(/*0*/ myArg: kotlin.Int)
internal final val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum>
}
@@ -0,0 +1,6 @@
enum class MyEnum(val myArg: Int) {
FIRST: <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!>MyEnum(1)<!>,
SECOND: <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!>MyEnum(2)<!>,
THIRD: <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!>MyEnum(3)<!>,
FOURTH: <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!>MyEnum(4)<!>
}
@@ -0,0 +1,60 @@
package
internal final enum class MyEnum : kotlin.Enum<MyEnum> {
public enum entry FIRST : MyEnum {
private constructor FIRST()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry SECOND : MyEnum {
private constructor SECOND()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry THIRD : MyEnum {
private constructor THIRD()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public enum entry FOURTH : MyEnum {
private constructor FOURTH()
internal final override /*1*/ /*fake_override*/ val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
private constructor MyEnum(/*0*/ myArg: kotlin.Int)
internal final val myArg: kotlin.Int
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: MyEnum): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
public final override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): MyEnum
public final /*synthesized*/ fun values(): kotlin.Array<MyEnum>
}
@@ -3,7 +3,7 @@
package enum
enum class HappyEnum {
CASE1
CASE1,
CASE2
}
@@ -3,7 +3,7 @@ public enum MyJavaEnum {}
// FILE: test.kt
<!OPEN_MODIFIER_IN_ENUM!>open<!> enum class MyEnum() {
A: MyEnum()
A()
}
enum class MyEnum2() {}
@@ -1,5 +1,5 @@
enum class E {
ABC
ABC;
enum class F {
DEF
@@ -1,5 +1,5 @@
private enum class MethodKind {
INSTANCE
INSTANCE,
STATIC
}
@@ -2,7 +2,7 @@
fun foo() {
<!LOCAL_ENUM_NOT_ALLOWED!>enum class A<!> {
FOO
FOO,
BAR
}
val foo = A.FOO
@@ -1,23 +1,23 @@
enum class E {
<!ILLEGAL_MODIFIER!>public<!> <!ILLEGAL_MODIFIER!>final<!> SUBCLASS {
fun foo() {}
}
},
<!ILLEGAL_MODIFIER!>public<!> PUBLIC
<!ILLEGAL_MODIFIER!>protected<!> PROTECTED
<!ILLEGAL_MODIFIER!>private<!> PRIVATE
<!ILLEGAL_MODIFIER!>internal<!> INTERNAL
<!ILLEGAL_MODIFIER!>public<!> PUBLIC,
<!ILLEGAL_MODIFIER!>protected<!> PROTECTED,
<!ILLEGAL_MODIFIER!>private<!> PRIVATE,
<!ILLEGAL_MODIFIER!>internal<!> INTERNAL,
<!ILLEGAL_MODIFIER!>abstract<!> ABSTRACT
<!ILLEGAL_MODIFIER!>open<!> OPEN
<!ILLEGAL_MODIFIER!>override<!> OVERRIDE
<!ILLEGAL_MODIFIER!>final<!> FINAL
<!ILLEGAL_MODIFIER!>abstract<!> ABSTRACT,
<!ILLEGAL_MODIFIER!>open<!> OPEN,
<!ILLEGAL_MODIFIER!>override<!> OVERRIDE,
<!ILLEGAL_MODIFIER!>final<!> FINAL,
<!ILLEGAL_MODIFIER!>inner<!> INNER
<!ILLEGAL_MODIFIER!>annotation<!> ANNOTATION
<!ILLEGAL_MODIFIER!>enum<!> ENUM
<!ILLEGAL_MODIFIER!>out<!> OUT
<!ILLEGAL_MODIFIER!>in<!> IN
<!ILLEGAL_MODIFIER!>vararg<!> VARARG
<!ILLEGAL_MODIFIER!>inner<!> INNER,
<!ILLEGAL_MODIFIER!>annotation<!> ANNOTATION,
<!ILLEGAL_MODIFIER!>enum<!> ENUM,
<!ILLEGAL_MODIFIER!>out<!> OUT,
<!ILLEGAL_MODIFIER!>in<!> IN,
<!ILLEGAL_MODIFIER!>vararg<!> VARARG,
<!ILLEGAL_MODIFIER!>reified<!> REIFIED
}
@@ -2,12 +2,12 @@ enum class EnumWithOpenMembers {
E1 {
override fun foo() = 1
override val bar: String = "a"
}
},
E2 {
<!OVERRIDING_FINAL_MEMBER!>override<!> fun f() = 3
<!OVERRIDING_FINAL_MEMBER!>override<!> val b = 4
}
};
open fun foo() = 1
open val bar: String = ""
@@ -2,8 +2,8 @@
package foo
enum class E {
ENTRY
ANOTHER
ENTRY,
ANOTHER;
class Nested {
companion object {
@@ -3,5 +3,5 @@
package bug
public enum class Foo<!TYPE_PARAMETERS_IN_ENUM!><T><!> {
A : Foo<String>()
A : <!ENUM_ENTRY_USES_DEPRECATED_SUPER_CONSTRUCTOR!>Foo<String>()<!>
}
@@ -1,5 +1,5 @@
enum class E {
ENTRY
ENTRY;
companion object {
fun foo(): E = ENTRY
@@ -36,7 +36,7 @@ class A {
}
enum class E {
E1 E2
E1, E2
}
object B {
@@ -1,6 +1,6 @@
enum class E {
A
B
A,
B,
C
}
@@ -2,7 +2,7 @@
package a
enum class SomeEnum {
FIRST
FIRST,
SECOND
}
@@ -2,7 +2,7 @@
package a
enum class TestEnum {
FIRST
FIRST,
SECOND
}
@@ -2,8 +2,8 @@ import Kind.EXT_RETURN
import Kind.GLOBAL_RETURN
enum class Kind {
LOCAL
EXT_RETURN
LOCAL,
EXT_RETURN,
GLOBAL_RETURN
}
@@ -1,10 +1,10 @@
enum class E {
E1 {
override fun foo() = outerFun() + super.outerFun()
}
},
E2 {
override fun foo() = E1.foo()
}
};
abstract fun foo(): Int
@@ -17,7 +17,7 @@ class D {
enum class H {
<!ILLEGAL_MODIFIER!>inner<!> I {
inner class II
}
};
inner class J
}
@@ -1,6 +1,6 @@
enum class E {
E1
E2 { }
E1,
E2 { };
}
fun foo() = E.E1
@@ -1,7 +1,7 @@
class A {
enum class E {
E1
E2 { }
E1,
E2 { };
}
}
@@ -38,8 +38,8 @@ class J {
}
<!ILLEGAL_MODIFIER!>companion<!> enum class Enum {
E1
E2
E1,
E2;
companion object
}
@@ -1,7 +1,7 @@
enum class E {
FIRST
FIRST,
SECOND
SECOND;
companion object {
class FIRST
@@ -11,9 +11,9 @@ object Foo {
<!CONFLICTING_OVERLOADS!>fun En()<!> = 239
enum class <!CONFLICTING_OVERLOADS!>En<!> {
ENTRY
ENTRY,
SUBCLASS { }
SUBCLASS { };
fun ENTRY() = 42
@@ -3,24 +3,24 @@
package kt2418
enum class A {
<!REDECLARATION!>FOO<!>
<!REDECLARATION!>FOO<!>,
<!REDECLARATION!>FOO<!>
}
enum class B {
FOO
FOO;
fun FOO() {}
}
enum class C {
<!REDECLARATION!>FOO<!>
<!REDECLARATION!>FOO<!>;
val <!REDECLARATION!>FOO<!> = 1
}
enum class D {
<!REDECLARATION!>FOO<!>
<!REDECLARATION!>FOO<!>;
class <!REDECLARATION!>FOO<!> {}
}
@@ -1,11 +1,11 @@
enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
},
TALKING {
override fun signal() = ProtocolState.WAITING
}
};
abstract fun signal() : ProtocolState
}
@@ -1,11 +1,11 @@
enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
},
TALKING {
override fun signal() = ProtocolState.WAITING
}
};
abstract fun signal() : ProtocolState
}
@@ -4,7 +4,7 @@ import DOMElementTestClasses.cls2
// use case 1
enum class DOMElementTestClasses {
cls1 cls2
cls1, cls2;
fun invoke() {}
}
@@ -4,7 +4,7 @@ object A {
}
enum class B {
X : B() {
X() {
<!SECONDARY_CONSTRUCTOR_IN_OBJECT!>constructor()
<!>}
}
@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
enum class A {
W: A(1) X: A(1, 2) Y: A(3.0) Z: A("") E: A()
W(1), X(1, 2), Y(3.0), Z(""), E();
constructor()
constructor(x: Int)
@@ -10,7 +10,7 @@ enum class A {
}
enum class B(x: Int) {
W: B(1) X: B(1, 2) Y: B(3.0) Z: B("")
W(1), X(1, 2), Y(3.0), Z("");
constructor(x: Int, y: Int): this(x+y)
constructor(x: Double): this(x.toInt(), 1)
@@ -18,20 +18,20 @@ enum class B(x: Int) {
}
enum class C {
EMPTY: C() // may be we should avoid explicit call here
EMPTY(); // may be we should avoid explicit call here
constructor()
}
enum class D(val prop: Int) {
X: D(123) {
X(123) {
override fun f() = 1
}
Y: D() {
},
Y() {
override fun f() = prop
}
Z: D("abc") {
},
Z("abc") {
override fun f() = prop
}
};
constructor(): this(1)
constructor(x: String): this(x.length())
@@ -2,7 +2,7 @@
// FILE: 1.kt
enum class E { A B }
enum class E { A, B }
fun test(e: E?) = <!NO_ELSE_IN_WHEN!>when<!> (e) {
E.A -> 1
@@ -1,4 +1,4 @@
enum class E { A B }
enum class E { A, B }
fun foo(e: E, something: Any?): Int {
if (something != null) return 0
@@ -22,7 +22,7 @@ class A {
}
<!NON_TOPLEVEL_CLASS_DECLARATION!>enum class E<!> {
X Y
X, Y;
companion object {}
}
@@ -52,7 +52,7 @@ interface T {
}
<!NON_TOPLEVEL_CLASS_DECLARATION!>enum class E<!> {
X Y
X, Y;
companion object {}
}
@@ -61,7 +61,7 @@ interface T {
}
enum class E {
X Y
X, Y;
<!NON_TOPLEVEL_CLASS_DECLARATION!>class B<!> {
<!NON_TOPLEVEL_CLASS_DECLARATION!>class C<!>
@@ -86,7 +86,7 @@ enum class E {
}
<!NON_TOPLEVEL_CLASS_DECLARATION!>enum class E<!> {
X Y
X, Y;
companion object {}
}
@@ -4176,6 +4176,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("enumCommaNoSemicolon.kt")
public void testEnumCommaNoSemicolon() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumCommaNoSemicolon.kt");
doTest(fileName);
}
@TestMetadata("enumEntryCannotHaveClassObject.kt")
public void testEnumEntryCannotHaveClassObject() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumEntryCannotHaveClassObject.kt");
@@ -4206,6 +4212,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("enumMissedComma.kt")
public void testEnumMissedComma() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumMissedComma.kt");
doTest(fileName);
}
@TestMetadata("enumMissingName.kt")
public void testEnumMissingName() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumMissingName.kt");
@@ -4218,6 +4230,36 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("enumNoComma.kt")
public void testEnumNoComma() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumNoComma.kt");
doTest(fileName);
}
@TestMetadata("enumNoSemicolon.kt")
public void testEnumNoSemicolon() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumNoSemicolon.kt");
doTest(fileName);
}
@TestMetadata("enumOldConstructor.kt")
public void testEnumOldConstructor() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumOldConstructor.kt");
doTest(fileName);
}
@TestMetadata("enumOldConstructorNamedArgument.kt")
public void testEnumOldConstructorNamedArgument() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumOldConstructorNamedArgument.kt");
doTest(fileName);
}
@TestMetadata("enumOldConstructors.kt")
public void testEnumOldConstructors() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumOldConstructors.kt");
doTest(fileName);
}
@TestMetadata("enumStarImport.kt")
public void testEnumStarImport() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/enumStarImport.kt");
+1 -1
View File
@@ -1,5 +1,5 @@
enum class E {
ENTRY
ENTRY;
companion object {
fun foo(): E = ENTRY
+1 -1
View File
@@ -5,7 +5,7 @@ val <error>a</error> : Int = 1
<error>fun foo()</error> {}
enum class EnumClass {
<error>FOO</error>
<error>FOO</error>,
<error>FOO</error>
}
@@ -1,7 +1,7 @@
// KT-3750 When without else
enum class A {
e1
e1,
e2
}
class B(val a: A)
+2 -2
View File
@@ -1,11 +1,11 @@
enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
},
TALKING {
override fun signal() = ProtocolState.WAITING
}
};
abstract fun signal() : ProtocolState
}
+2 -2
View File
@@ -1,11 +1,11 @@
enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
},
TALKING {
override fun signal() = ProtocolState.WAITING
}
};
abstract fun signal() : ProtocolState
}
+1 -1
View File
@@ -1,7 +1,7 @@
package testing
<info textAttributesKey="KOTLIN_BUILTIN_ANNOTATION">enum</info> class <info textAttributesKey="KOTLIN_CLASS">Test</info> {
<info textAttributesKey="KOTLIN_CLASS">FIRST</info>
<info textAttributesKey="KOTLIN_CLASS">FIRST</info>,
<info textAttributesKey="KOTLIN_CLASS">SECOND</info>
}