Prohibit to override equals/hashCode in enums
#KT-5721 Fixed
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
enum class E {
|
||||
ENTRY;
|
||||
|
||||
<!OVERRIDING_FINAL_MEMBER!>override<!> fun name(): String = "lol"
|
||||
<!OVERRIDING_FINAL_MEMBER!>override<!> fun ordinal(): Int = 0
|
||||
|
||||
<!OVERRIDING_FINAL_MEMBER!>override<!> fun equals(other: Any?) = true
|
||||
<!OVERRIDING_FINAL_MEMBER!>override<!> fun hashCode() = -1
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
internal final enum class E : kotlin.Enum<E> {
|
||||
private constructor E()
|
||||
public open override /*1*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ fun name(): kotlin.String
|
||||
public open override /*1*/ fun ordinal(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public enum entry ENTRY : E {
|
||||
private constructor ENTRY()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun ordinal(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public class object <class-object-for-ENTRY> : E.ENTRY {
|
||||
private constructor <class-object-for-ENTRY>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
public open 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): E
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<E>
|
||||
}
|
||||
@@ -3907,6 +3907,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("overrideFinalEnumMethods.kt")
|
||||
public void testOverrideFinalEnumMethods() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/overrideFinalEnumMethods.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("starImportNestedClassAndEntries.kt")
|
||||
public void testStarImportNestedClassAndEntries() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/enum/starImportNestedClassAndEntries.kt");
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
public abstract class Enum<E: Enum<E>>(name: String, ordinal: Int) {
|
||||
public final fun name() : String
|
||||
public final fun ordinal() : Int
|
||||
public abstract class Enum<E : Enum<E>>(name: String, ordinal: Int) {
|
||||
public final fun name(): String
|
||||
public final fun ordinal(): Int
|
||||
|
||||
public override final fun equals(other: Any?): Boolean
|
||||
public override final fun hashCode(): Int
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user