Make 'Enum' the supertype of enums, not an interface.

CFE already does this, and it seems to be a change necessary for
enhanced enums.

Change-Id: If70e1ea66c946a61cc48410867ebdad023662740
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222322
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Konstantin Shcheglov 2021-12-07 22:02:00 +00:00
parent 2b4934a54d
commit 89f2e89719
3 changed files with 34 additions and 55 deletions

View file

@ -2790,10 +2790,7 @@ class EnumElementImpl extends AbstractClassElementImpl {
bool get hasStaticMember => true;
@override
List<InterfaceType> get interfaces {
var enumType = library.typeProvider.enumType;
return enumType != null ? <InterfaceType>[enumType] : const [];
}
List<InterfaceType> get interfaces => const [];
@override
bool get isAbstract => false;
@ -2834,7 +2831,10 @@ class EnumElementImpl extends AbstractClassElementImpl {
}
@override
InterfaceType get supertype => library.typeProvider.objectType;
InterfaceType get supertype {
var enumType = library.typeProvider.enumType;
return enumType ?? library.typeProvider.objectType;
}
@override
List<TypeParameterElement> get typeParameters =>

View file

@ -3188,6 +3188,10 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
/// See [CompileTimeErrorCode.MIXIN_INHERITS_FROM_NOT_OBJECT].
bool _checkForMixinInheritsNotFromObject(
NamedType mixinName, ClassElement mixinElement) {
if (mixinElement.isEnum) {
return false;
}
var mixinSupertype = mixinElement.supertype;
if (mixinSupertype == null || mixinSupertype.isDartCoreObject) {
var mixins = mixinElement.mixins;

View file

@ -7681,8 +7681,7 @@ library
enum E @5
codeOffset: 0
codeLength: 26
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -12846,8 +12845,7 @@ library
synthetic @-1
enums
enum E @30
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -15065,8 +15063,7 @@ library
definingUnit
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -15119,8 +15116,7 @@ library
definingUnit
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -16087,8 +16083,7 @@ library
definingUnit
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -16111,8 +16106,7 @@ library
synthetic toString @-1
returnType: String
enum E @19
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -16369,8 +16363,7 @@ library
enums
enum E @65
documentationComment: /**\n * Docs\n */
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -16406,8 +16399,7 @@ library
definingUnit
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -16454,8 +16446,7 @@ library
definingUnit
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -16515,8 +16506,7 @@ library
definingUnit
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -16548,8 +16538,7 @@ library
definingUnit
enums
enum E1 @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -16568,8 +16557,7 @@ library
synthetic toString @-1
returnType: String
enum E2 @20
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -16655,8 +16643,7 @@ library
superKeyword: super @0
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -23412,8 +23399,7 @@ library
definingUnit
enums
enum E @19
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -23483,8 +23469,7 @@ library
returnType: dynamic
enums
enum E @64
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -23558,8 +23543,7 @@ library
staticElement: self::@getter::a
staticType: null
token: a @15
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -25055,8 +25039,7 @@ library
staticElement: self::@getter::foo
staticType: null
token: foo @17
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -26247,8 +26230,7 @@ library
synthetic @-1
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -27547,8 +27529,7 @@ library
definingUnit
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -29509,8 +29490,7 @@ library
synthetic @-1
enums
enum E @16
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -29617,8 +29597,7 @@ library
synthetic @-1
enums
enum E @27
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -29659,8 +29638,7 @@ library
synthetic @-1
enums
enum E @42
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -29738,8 +29716,7 @@ library
synthetic @-1
enums
enum E @27
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -29815,8 +29792,7 @@ library
synthetic @-1
enums
enum E @27
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int
@ -29960,8 +29936,7 @@ library
definingUnit
enums
enum E @5
interfaces
Enum
supertype: Enum
fields
synthetic final index @-1
type: int