Skip to content

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

@stereotype441

Description

@stereotype441

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.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions