Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3774)

Unified Diff: pkg/analyzer/lib/src/generated/type_system.dart

Issue 2381773002: fix #27410, subtype should not use DartType.== (Closed)
Patch Set: comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/type_system.dart
diff --git a/pkg/analyzer/lib/src/generated/type_system.dart b/pkg/analyzer/lib/src/generated/type_system.dart
index 0488553c43014ca14e9210c463bb5279263b57a8..5574aed89f2b09b3e9abf83af23f13bfb8b2f982 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -848,15 +848,15 @@ class StrongTypeSystemImpl extends TypeSystem {
bool _isInterfaceSubtypeOf(
InterfaceType i1, InterfaceType i2, Set<Element> visited) {
+ if (identical(i1, i2)) {
+ return true;
+ }
+
// Guard recursive calls
_GuardedSubtypeChecker<InterfaceType> guardedInterfaceSubtype = _guard(
(DartType i1, DartType i2, Set<Element> visited) =>
_isInterfaceSubtypeOf(i1, i2, visited));
- if (i1 == i2) {
- return true;
- }
-
if (i1.element == i2.element) {
List<DartType> tArgs1 = i1.typeArguments;
List<DartType> tArgs2 = i2.typeArguments;
@@ -902,13 +902,14 @@ class StrongTypeSystemImpl extends TypeSystem {
bool _isSubtypeOf(DartType t1, DartType t2, Set<Element> visited,
{bool dynamicIsBottom: false}) {
+ if (identical(t1, t2)) {
+ return true;
+ }
+
// Guard recursive calls
_GuardedSubtypeChecker<DartType> guardedSubtype = _guard(_isSubtypeOf);
_GuardedSubtypeChecker<DartType> guardedInferTypeParameter =
_guard(_inferTypeParameterSubtypeOf);
- if (t1 == t2) {
- return true;
- }
// The types are void, dynamic, bottom, interface types, function types,
// and type parameters. We proceed by eliminating these different classes
@@ -928,10 +929,12 @@ class StrongTypeSystemImpl extends TypeSystem {
// S <: T where S is a type variable
// T is not dynamic or object (handled above)
- // S != T (handled above)
- // So only true if bound of S is S' and
- // S' <: T
+ // True if T == S
+ // Or true if bound of S is S' and S' <: T
if (t1 is TypeParameterType) {
+ if (t1 == t2) {
+ return true;
+ }
if (guardedInferTypeParameter(t1, t2, visited)) {
return true;
}
@@ -950,7 +953,7 @@ class StrongTypeSystemImpl extends TypeSystem {
// TODO(rnystrom): Determine how this can ever be reached. If it can't,
// remove it.
if (t1.isVoid || t2.isVoid) {
- return false;
+ return t1.isVoid && t2.isVoid;
}
// We've eliminated void, dynamic, bottom, and type parameters. The only
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698