Skip to content
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

Analyzer erroneously rejects use of nullable extension type representation variable via type parameter #57004

Open
stereotype441 opened this issue Oct 31, 2024 · 1 comment
Assignees
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@stereotype441
Copy link
Member

The analyzer rejects the following code, but the CFE accepts it:

extension type E(int? value) {}

test<T extends E>(T t) => t.value; // ERROR

The analyzer's error message is: The property 'value' can't be unconditionally accessed because the receiver can be 'null'. It's true that the receiver (t) can be null (because the extension type's representation type is nullable), but that's not a problem; it's still safe to access the property value.

@stereotype441 stereotype441 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-spec Issues with the analyzer's implementation of the language spec labels Oct 31, 2024
@stereotype441
Copy link
Member Author

I'm going to work on this.

@stereotype441 stereotype441 self-assigned this Oct 31, 2024
@srawlins srawlins added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants