Skip to content

Analyzer uses static type when determining constructor tear-off identity. #54358

Open
@lrhn

Description

@lrhn

Example:

void main() {
  const c1 = identical(C<int>.new, C<int>.new) ? 0 : (1 ~/ 0);  
  const c2 = identical(C<ExInt>.new, C<ExInt>.new) ? 0 : (1 ~/ 0);  
  const c3 = identical(C<ExInt>.new, C<int>.new) ? 0 : (1 ~/ 0);   /// Fails in analyzer
  const c4 = identical(C<ExInt>, C<int>) ? 0 : (1 ~/ 0);  
}
extension type const ExInt(int _) implements int {}
class C<T> {
  C();
}

The analyzer considers the constants C<ExInt>.new and C<int>.new different. The values of those should be the same (as C<int>.new), because the values only use extension-type-erased types. The static type is different, but identical shouldn't care.

CFE has no issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestanalyzer-constantsarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.dart-model-analyzer-specIssues with the analyzer's implementation of the language specfeature-extension-typesImplementation of the extension type featuretype-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