Skip to content

No error reported when a const makes explicit use of a type parameter #33439

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
stereotype441 opened this issue Jun 13, 2018 · 2 comments
Closed
Labels
legacy-area-analyzer Use area-devexp instead. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Milestone

Comments

@stereotype441
Copy link
Member

Consider the following code:

class C<T> {
  const C();
}

class D<T> {
  final x = const C<T>(); // (1)
}

main() {
  print(new D<int>().x.runtimeType);
}

The VM, dart2js, and the common front end agree that this code has an error at the line marked (1), because a constant expression cannot refer to type variables in enclosing scopes.

The analyzer reports no error.

@sigmundch
Copy link
Member

DBC

I should note that we have run into this a few times with internal customers when defining default values. The most subtle case has been when using a generic function, which gets instantiated with a class type variable implicitly. You can find examples in #33438

@MichaelRFairhurst
Copy link
Contributor

Saw this while investigating #32913 and thought it'd be a good place to start.....however, this is already fixed, it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants