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

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

Issue 1686893002: Consolidate the code that replaces a TypeParameter with its bound. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Add unit tests. Created 4 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
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 16e0817f8943c8acd93f69453fda4f14d9367f7f..6a285914a48619412100ce36b4d064d6da3a6833 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -622,26 +622,12 @@ class TypeSystemImpl implements TypeSystem {
if (type2.isBottom) {
return type1;
}
+
// Let U be a type variable with upper bound B. The least upper bound of U
// and a type T is the least upper bound of B and T.
- while (type1 is TypeParameterType) {
- // TODO(paulberry): is this correct in the complex of F-bounded
- // polymorphism?
- DartType bound = (type1 as TypeParameterType).element.bound;
- if (bound == null) {
- bound = typeProvider.objectType;
- }
- type1 = bound;
- }
- while (type2 is TypeParameterType) {
- // TODO(paulberry): is this correct in the context of F-bounded
- // polymorphism?
- DartType bound = (type2 as TypeParameterType).element.bound;
- if (bound == null) {
- bound = typeProvider.objectType;
- }
- type2 = bound;
- }
+ type1 = type1.resolveToBound(typeProvider.objectType);
+ type2 = type2.resolveToBound(typeProvider.objectType);
+
// The least upper bound of a function type and an interface type T is the
// least upper bound of Function and T.
if (type1 is FunctionType && type2 is InterfaceType) {
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698