Skip to content

CFE: support type arguments for enum classes used in types #48141

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
alexmarkov opened this issue Jan 13, 2022 · 1 comment
Closed

CFE: support type arguments for enum classes used in types #48141

alexmarkov opened this issue Jan 13, 2022 · 1 comment
Assignees
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@alexmarkov
Copy link
Contributor

This is a part of #47453.

Test co19/LanguageFeatures/Enhanced-Enum/semantics_A06_t02 fails with RuntimeError on the VM because CFE ignores type arguments of enum classes when they are used in types:

  Expect.isTrue(E.values[0] is E<A>);
  Expect.isFalse(E.values[0] is E<B>);

Kernel:

    exp::Expect::isTrue(#C10.{core::List::[]}(0){(core::int) → sem::E<dynamic>} is{ForNonNullableByDefault} sem::E<dynamic>);
    exp::Expect::isFalse(#C10.{core::List::[]}(0){(core::int) → sem::E<dynamic>} is{ForNonNullableByDefault} sem::E<dynamic>);

So type E<A> was translated to E<dynamic>.

Note that enum values look correct:

    static const field core::List<sem::E<dynamic>> values = #C10;
    static const field sem::E<sem::A> e1 = #C3;
    static const field sem::E<sem::B> e2 = #C6;
    static const field sem::E<sem::C> e3 = #C9;

  #C1 = 0
  #C2 = "e1"
  #C3 = sem::E<sem::A> {index:#C1, _name:#C2}
  #C4 = 1
  #C5 = "e2"
  #C6 = sem::E<sem::B> {index:#C4, _name:#C5}
  #C7 = 2
  #C8 = "e3"
  #C9 = sem::E<sem::C> {index:#C7, _name:#C8}
  #C10 = <sem::E<dynamic>>[#C3, #C6, #C9]

@chloestefantsova Could you please take a look?

@alexmarkov alexmarkov added the legacy-area-front-end Legacy: Use area-dart-model instead. label Jan 13, 2022
@chloestefantsova
Copy link
Contributor

Thanks for spotting that! I'm working on a fix at https://dart-review.googlesource.com/c/sdk/+/228202.

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