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

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

Issue 2662973005: Suppress NO_DEFAULT_BOUND errors. (Closed)
Patch Set: Created 3 years, 11 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 | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/strong_mode_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 b951f4f4dff2f4099045d17b8f5858af7ee0475e..bcf8ad566db77cad173eeaf664aefd8ce4d7a479 100644
--- a/pkg/analyzer/lib/src/generated/type_system.dart
+++ b/pkg/analyzer/lib/src/generated/type_system.dart
@@ -58,14 +58,14 @@ class StrongTypeSystemImpl extends TypeSystem {
{this.implicitCasts: true,
this.nonnullableTypes: AnalysisOptionsImpl.NONNULLABLE_TYPES});
+ @override
+ bool get isStrong => true;
+
bool anyParameterType(FunctionType ft, bool predicate(DartType t)) {
return ft.parameters.any((p) => predicate(p.type));
}
@override
- bool get isStrong => true;
-
- @override
FunctionType functionTypeToConcreteType(FunctionType t) {
// TODO(jmesserly): should we use a real "fuzzyArrow" bit on the function
// type? That would allow us to implement this in the subtype relation.
@@ -371,13 +371,26 @@ class StrongTypeSystemImpl extends TypeSystem {
}
// If we stopped making progress, and not all types are ground,
- // then the whole type is malbounded and an error should be reported.
+ // then the whole type is malbounded and an error should be reported
+ // if errors are requested, and a partially completed type should
+ // be returned.
if (partials.isNotEmpty) {
if (hasError != null) {
hasError[0] = true;
}
- return instantiateType(
- type, new List<DartType>.filled(count, DynamicTypeImpl.instance));
+ var domain = defaults.keys.toList();
+ var range = defaults.values.toList();
+ // Build a substitution Phi mapping each uncompleted type variable to
+ // dynamic, and each completed type variable to its default.
+ for (TypeParameterType parameter in partials.keys) {
+ domain.add(parameter);
+ range.add(DynamicTypeImpl.instance);
+ }
+ // Set the default for an uncompleted type variable (T extends B)
+ // to be Phi(B)
+ for (TypeParameterType parameter in partials.keys) {
+ defaults[parameter] = partials[parameter].substitute2(range, domain);
+ }
}
List<DartType> orderedArguments =
« no previous file with comments | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | pkg/analyzer/test/generated/strong_mode_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698