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

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

Issue 1499813002: Downwards inference on non-generic constructor parameters (fixes #25106) (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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/src/task/strong/inferred_type_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/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 5ae521c68693e101e739304ae1cbe9dcffd1c49c..0d17e7260d451a3d113f8867aede0054dcee9bee 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -11715,12 +11715,12 @@ class ResolverVisitor extends ScopedVisitor {
@override
Object visitInstanceCreationExpression(InstanceCreationExpression node) {
- DartType contextType = InferenceContext.getType(node);
- if (contextType is InterfaceType &&
- contextType.typeArguments != null &&
- contextType.typeArguments.length > 0) {
- TypeName classTypeName = node.constructorName.type;
- if (classTypeName.typeArguments == null) {
+ TypeName classTypeName = node.constructorName.type;
+ if (classTypeName.typeArguments == null) {
+ DartType contextType = InferenceContext.getType(node);
+ if (contextType is InterfaceType &&
+ contextType.typeArguments != null &&
+ contextType.typeArguments.length > 0) {
List<DartType> targs =
inferenceContext.matchTypes(classTypeName.type, contextType);
if (targs != null && targs.any((t) => !t.isDynamic)) {
@@ -11731,24 +11731,17 @@ class ResolverVisitor extends ScopedVisitor {
// The element resolver uses the type on the constructor name, so
// infer it first
typeAnalyzer.inferConstructorName(node.constructorName, fullType);
- safelyVisit(node.constructorName);
- ConstructorElement invokedConstructor =
- node.constructorName.staticElement;
- FunctionType rawConstructorType = invokedConstructor.type;
- FunctionType constructorType = rawConstructorType.substitute2(
- targs, rawConstructorType.typeArguments);
- InferenceContext.setType(node.argumentList, constructorType);
- safelyVisit(node.argumentList);
- InferenceContext.setType(node, fullType);
- node.accept(elementResolver);
- node.accept(typeAnalyzer);
- return null;
}
- } else {
- InferenceContext.clearType(node);
}
}
- super.visitInstanceCreationExpression(node);
+ safelyVisit(node.constructorName);
+ FunctionType constructorType = node.constructorName.staticElement?.type;
+ if (constructorType != null) {
+ InferenceContext.setType(node.argumentList, constructorType);
+ }
+ safelyVisit(node.argumentList);
+ node.accept(elementResolver);
+ node.accept(typeAnalyzer);
return null;
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/strong/inferred_type_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698