Skip to content

DartType.isEquivalentTo should be cleaned up #35331

@stereotype441

Description

@stereotype441

The existence of the DartType.isEquivalentTo method is confusing. Two DartType objects should be considered equal (and have the same hashCode) if and only if the represent the same type as defined by the spec.

So for instance, given the typedef:

typedef void F<T>(); // T is not used!

F<int>, F<bool>, and () -> void all represent the same type in the eyes of the spec. The analyzer's isEquivalentTo method reports that they are equivalent, but operator== and hashCode treat them as different.

We should fix this so that operator== and hashCode treat the types as equivalent.

I suspect this will require substantial rework of the FunctionType class.

For more details see comments in https://dart-review.googlesource.com/c/sdk/+/86222/2/pkg/analyzer/lib/dart/element/type.dart.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onanalyzer-apiIssues that impact the public API of the analyzer packagelegacy-area-analyzerUse area-devexp instead.type-code-healthInternal changes to our tools and workflows to make them cleaner, simpler, or more maintainable

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions