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

Unified Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2002353006: Fix some corner cases of inferring type parameters from bounds. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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/lib/src/summary/link.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/element/element.dart
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 923ae2ca96fe211c82c29282d60c6d9bedbc04f5..d46c864189b0b3cf1b6516337cd738da05af5e83 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -6631,6 +6631,21 @@ abstract class TypeParameterizedElementMixin
List<UnlinkedTypeParam> get unlinkedTypeParams;
/**
+ * Determine the default value of type argument [i]. in most cases this will
+ * be `dynamic`, but sometimes it will be the bound of the ith type parameter.
+ */
+ DartType computeDefaultTypeArgument(int i) {
+ // If strong mode is off, or we can tell quickly from the summary that there
+ // is no bound, then the default type argument is `dynamic`; we don't have
+ // to call `typeParameters` to find that out.
+ if (!context.analysisOptions.strongMode ||
+ (unlinkedTypeParams != null && unlinkedTypeParams[i].bound == null)) {
+ return DynamicTypeImpl.instance;
+ }
+ return typeParameters[i].bound ?? DynamicTypeImpl.instance;
+ }
+
+ /**
* Convert the given [index] into a type parameter type.
*/
TypeParameterType getTypeParameterType(int index) {
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/summary/link.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698