Skip to content

[Enhanced enums] No error in CFE when Enum subtype overrides index #48353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sgrekhov opened this issue Feb 9, 2022 · 1 comment
Closed

[Enhanced enums] No error in CFE when Enum subtype overrides index #48353

sgrekhov opened this issue Feb 9, 2022 · 1 comment
Assignees
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Feb 9, 2022

The following co19 test fails in CFE now

abstract class E1 extends Enum {
  int get index => 42; // No expected error here in CFE
//        ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

abstract class E2 extends Enum {
  List<E2> get index => [];
//             ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
  print(E1);
  print(E2);
}

According to the specification

It's a compile-time error if a class, mixin or enum declaration has Enum as a superinterface, and it declares a non-abstract instance member named index. That member would override the index getter inherited from Enum, and we currently do not allow that.

So there should be an error.

Tested on Dart SDK version: 2.17.0-edge.21a5f734562eb0d2fca0f9b5b646632fbcdb04cb (be) (Wed Feb 9 02:28:41 2022 +0000) on "linux_x64"

UPD There is no expected error in CFE on the enum as well

enum E1 {
  e1,
  e2;

  final int index = 42; // No expected error on CFE
//          ^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

2 participants