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

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

Issue 2115173002: fix #25220, infer generic type from constructor arguments (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: update tests to be AST summary friendly Created 4 years, 5 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/CHANGELOG.md ('k') | pkg/analyzer/lib/src/generated/static_type_analyzer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 15c41d6218239ff744561fdab9bb3775ba2e2c5d..6ecb610d825e1b4468018398649e6b2fee0b0189 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -6723,6 +6723,16 @@ class ResolverVisitor extends ScopedVisitor {
if (contextType is InterfaceType &&
contextType.typeArguments != null &&
contextType.typeArguments.length > 0) {
+ // TODO(jmesserly): for generic methods we use the
+ // StrongTypeSystemImpl.inferGenericFunctionCall, which appears to
+ // be a tad more powerful than matchTypes.
+ //
+ // For example it can infer this case:
+ //
+ // class E<S, T> extends A<C<S>, T> { ... }
+ // A<C<int>, String> a0 = /*infer<int, String>*/new E("hello");
+ //
+ // See _inferArgumentTypesFromContext in this file for use of it.
List<DartType> targs =
inferenceContext.matchTypes(classTypeName.type, contextType);
if (targs != null && targs.any((t) => !t.isDynamic)) {
« no previous file with comments | « pkg/analyzer/CHANGELOG.md ('k') | pkg/analyzer/lib/src/generated/static_type_analyzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698