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

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

Issue 2699053002: treat void as a top type, analyzer fix for #28763
Patch Set: Created 3 years, 10 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 | pkg/analyzer/test/generated/type_system_test.dart » ('j') | 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 1e1d1824caf386948df9cb9b1832c51cb8801a16..50eca45ae4bced7437c0fac9e76124fda427b720 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -30,7 +30,7 @@ bool _isTop(DartType t, {bool dynamicIsBottom: false}) {
if (t.isDartAsyncFutureOr) {
return _isTop((t as InterfaceType).typeArguments[0]);
}
- return (t.isDynamic && !dynamicIsBottom) || t.isObject;
+ return (t.isDynamic && !dynamicIsBottom) || t.isObject || t.isVoid;
}
typedef bool _GuardedSubtypeChecker<T>(T t1, T t2, Set<Element> visited);
@@ -136,17 +136,6 @@ class StrongTypeSystemImpl extends TypeSystem {
return type1;
}
- // Treat void as top-like for GLB. This only comes into play with the
- // return types of two functions whose GLB is being taken. We allow a
- // non-void-returning function to subtype a void-returning one, so match
- // that logic here by treating the non-void arm as the subtype for GLB.
- if (type1.isVoid) {
- return type2;
- }
- if (type2.isVoid) {
- return type1;
- }
-
// Function types have structural GLB.
if (type1 is FunctionType && type2 is FunctionType) {
return _functionGreatestLowerBound(type1, type2);
@@ -889,16 +878,6 @@ class StrongTypeSystemImpl extends TypeSystem {
return false;
}
- // Void only appears as the return type of a function, and we handle it
- // directly in the function subtype rules. We should not get to a point
- // where we're doing a subtype test on a "bare" void, but just in case we
- // do, handle it safely.
- // TODO(rnystrom): Determine how this can ever be reached. If it can't,
- // remove it.
- if (t1.isVoid || t2.isVoid) {
- return t1.isVoid && t2.isVoid;
- }
-
// We've eliminated void, dynamic, bottom, type parameters, and FutureOr.
// The only cases are the combinations of interface type and function type.
@@ -1036,14 +1015,6 @@ abstract class TypeSystem {
_isBottom(type1, dynamicIsBottom: dynamicIsBottom)) {
return type2;
}
- // The least upper bound of void and any type T != dynamic is void.
- if (type1.isVoid) {
- return type1;
- }
- if (type2.isVoid) {
- return type2;
- }
-
if (type1 is TypeParameterType || type2 is TypeParameterType) {
return _typeParameterLeastUpperBound(type1, type2);
}
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/type_system_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698