mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 16:54:55 +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:
parent
293b6379b8
commit
05ddb78364
|
@ -88,8 +88,13 @@ class DartTypeEquivalence implements DartTypeVisitor1<bool, DartType> {
|
||||||
if (!nodeNamedParameters.containsKey(otherName) ||
|
if (!nodeNamedParameters.containsKey(otherName) ||
|
||||||
!nodeNamedParameters[otherName]!.accept1(this, otherType)) {
|
!nodeNamedParameters[otherName]!.accept1(this, otherType)) {
|
||||||
result = false;
|
result = false;
|
||||||
|
} else {
|
||||||
|
nodeNamedParameters.remove(otherName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (nodeNamedParameters.isNotEmpty) {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
if (!node.returnType.accept1(this, other.returnType)) {
|
if (!node.returnType.accept1(this, other.returnType)) {
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
|
@ -131,20 +136,10 @@ class DartTypeEquivalence implements DartTypeVisitor1<bool, DartType> {
|
||||||
while (result && nodeIndex < node.named.length) {
|
while (result && nodeIndex < node.named.length) {
|
||||||
NamedType nodeNamedType = node.named[nodeIndex];
|
NamedType nodeNamedType = node.named[nodeIndex];
|
||||||
NamedType otherNamedType = other.named[otherIndex];
|
NamedType otherNamedType = other.named[otherIndex];
|
||||||
int comparisonResult =
|
if (nodeNamedType.name != otherNamedType.name) {
|
||||||
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'.
|
|
||||||
result = false;
|
result = false;
|
||||||
|
} else {
|
||||||
|
result = nodeNamedType.type.accept1(this, otherNamedType.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue