Skip to content

False positive with the late keyword when using const factory constructor #1763

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
rrousselGit opened this issue Jul 28, 2021 · 2 comments
Closed
Labels
enhanced-const Requests or proposals about enhanced constant expressions request Requests to resolve a particular developer problem

Comments

@rrousselGit
Copy link

rrousselGit commented Jul 28, 2021

Consider the following code:

class Base {
  Base();

  const factory Base.empty() = _Empty;

  late final property = ...
}

class _Empty implements Base {
  const _Empty();

  @override
  get property => ...
}

This code currently does not compile with "Can't have a late final field in a class with a const constructor.
Try removing the 'late' modifier, or don't declare 'const' constructors."

This error is caused by a const factory. But since this is a factory constructor, this should not have any impact.

@rrousselGit rrousselGit added the request Requests to resolve a particular developer problem label Jul 28, 2021
@eernstg
Copy link
Member

eernstg commented Jul 28, 2021

True. Considering the issue in #1764.

@eernstg
Copy link
Member

eernstg commented Dec 1, 2021

Done in #1764.

@eernstg eernstg closed this as completed Dec 1, 2021
@eernstg eernstg added the enhanced-const Requests or proposals about enhanced constant expressions label Dec 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhanced-const Requests or proposals about enhanced constant expressions request Requests to resolve a particular developer problem
Projects
None yet
Development

No branches or pull requests

2 participants