Don't report unimplemented abstract for 'index' in enum.
Bug: https://github.com/dart-lang/sdk/issues/48438 Change-Id: I5d6357ce0dcff872a2f4b356359a19554833bf97 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233968 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
Commit Bot
parent
8774f7fd31
commit
774cafe41d
@@ -242,10 +242,16 @@ class _ClassVerifier {
|
||||
|
||||
// No concrete implementation of the name.
|
||||
if (concreteElement == null) {
|
||||
if (!_reportConcreteClassWithAbstractMember(name.name)) {
|
||||
inheritedAbstract ??= [];
|
||||
inheritedAbstract.add(interfaceElement);
|
||||
if (_reportConcreteClassWithAbstractMember(name.name)) {
|
||||
continue;
|
||||
}
|
||||
// We already reported ILLEGAL_ENUM_VALUES_INHERITANCE.
|
||||
if (classElement.isEnum &&
|
||||
const {'values', 'values='}.contains(name.name)) {
|
||||
continue;
|
||||
}
|
||||
inheritedAbstract ??= [];
|
||||
inheritedAbstract.add(interfaceElement);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,35 @@ abstract class B extends A implements Enum {}
|
||||
]);
|
||||
}
|
||||
|
||||
test_enum_method() async {
|
||||
test_enum_getter_fromImplements() async {
|
||||
await assertErrorsInCode(r'''
|
||||
class A {
|
||||
int get values => 0;
|
||||
}
|
||||
|
||||
enum E implements A {
|
||||
v
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 41, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_enum_method_fromImplements() async {
|
||||
await assertErrorsInCode(r'''
|
||||
class A {
|
||||
int values() => 0;
|
||||
}
|
||||
|
||||
enum E implements A {
|
||||
v
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 39, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_enum_method_fromWith() async {
|
||||
await assertErrorsInCode(r'''
|
||||
mixin M {
|
||||
int values() => 0;
|
||||
@@ -101,6 +129,34 @@ enum E with M {
|
||||
]);
|
||||
}
|
||||
|
||||
test_enum_setter_fromImplements() async {
|
||||
await assertErrorsInCode(r'''
|
||||
class A {
|
||||
set values(int _) {}
|
||||
}
|
||||
|
||||
enum E implements A {
|
||||
v
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 41, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_enum_setter_fromWith() async {
|
||||
await assertErrorsInCode(r'''
|
||||
mixin M {
|
||||
set values(int _) {}
|
||||
}
|
||||
|
||||
enum E with M {
|
||||
v
|
||||
}
|
||||
''', [
|
||||
error(CompileTimeErrorCode.ILLEGAL_ENUM_VALUES_INHERITANCE, 41, 1),
|
||||
]);
|
||||
}
|
||||
|
||||
test_mixin_field() async {
|
||||
await assertErrorsInCode(r'''
|
||||
class A {
|
||||
|
||||
Reference in New Issue
Block a user