1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-05 09:20:04 +00:00

[cfe] Make DartTypeEquivalence symmetrical for functions and records

Change-Id: I9963ae7401d1e31e07edf90146f411b6586dbc16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256664
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
Chloe Stefantsova 2022-09-07 09:11:11 +00:00 committed by Commit Bot
parent 293b6379b8
commit 05ddb78364

View File

@ -88,8 +88,13 @@ class DartTypeEquivalence implements DartTypeVisitor1<bool, DartType> {
if (!nodeNamedParameters.containsKey(otherName) ||
!nodeNamedParameters[otherName]!.accept1(this, otherType)) {
result = false;
} else {
nodeNamedParameters.remove(otherName);
}
}
if (nodeNamedParameters.isNotEmpty) {
result = false;
}
if (!node.returnType.accept1(this, other.returnType)) {
result = false;
}
@ -131,20 +136,10 @@ class DartTypeEquivalence implements DartTypeVisitor1<bool, DartType> {
while (result && nodeIndex < node.named.length) {
NamedType nodeNamedType = node.named[nodeIndex];
NamedType otherNamedType = other.named[otherIndex];
int comparisonResult =
nodeNamedType.name.compareTo(otherNamedType.name);
if (comparisonResult == 0) {
// nodeNamedType.name == otherNamedType.name
result = nodeNamedType.type.accept1(this, otherNamedType.type);
otherIndex++;
nodeIndex++;
} else if (comparisonResult < 0) {
// nodeNamedType.name < otherNamedType.name
nodeIndex++;
} else {
// nodeNamedType.name > otherNamedType.name
// 'otherNamedType.name' is not found in 'node.named'.
if (nodeNamedType.name != otherNamedType.name) {
result = false;
} else {
result = nodeNamedType.type.accept1(this, otherNamedType.type);
}
}