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

Side by Side Diff: pkg/analyzer/lib/src/task/strong/checker.dart

Issue 1579503005: fix #25409, error if a generic method argument did not have a corresponding parameter (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be 5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be
6 // refactored to fit into analyzer. 6 // refactored to fit into analyzer.
7 library analyzer.src.task.strong.checker; 7 library analyzer.src.task.strong.checker;
8 8
9 import 'package:analyzer/analyzer.dart'; 9 import 'package:analyzer/analyzer.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 checkAssignment(arg, expectedType); 122 checkAssignment(arg, expectedType);
123 } 123 }
124 124
125 void checkArgumentList(ArgumentList node, FunctionType type) { 125 void checkArgumentList(ArgumentList node, FunctionType type) {
126 NodeList<Expression> list = node.arguments; 126 NodeList<Expression> list = node.arguments;
127 int len = list.length; 127 int len = list.length;
128 for (int i = 0; i < len; ++i) { 128 for (int i = 0; i < len; ++i) {
129 Expression arg = list[i]; 129 Expression arg = list[i];
130 ParameterElement element = arg.staticParameterElement; 130 ParameterElement element = arg.staticParameterElement;
131 if (element == null) { 131 if (element == null) {
132 if (type.parameters.length < len) { 132 // We found an argument mismatch, the analyzer will report this too,
133 // We found an argument mismatch, the analyzer will report this too, 133 // so no need to insert an error for this here.
134 // so no need to insert an error for this here. 134 continue;
135 continue;
136 }
137 element = type.parameters[i];
138 // TODO(vsm): When can this happen?
139 assert(element != null);
140 } 135 }
141 DartType expectedType = _elementType(element); 136 DartType expectedType = _elementType(element);
142 if (expectedType == null) expectedType = DynamicTypeImpl.instance; 137 if (expectedType == null) expectedType = DynamicTypeImpl.instance;
143 checkArgument(arg, expectedType); 138 checkArgument(arg, expectedType);
144 } 139 }
145 } 140 }
146 141
147 void checkAssignment(Expression expr, DartType type) { 142 void checkAssignment(Expression expr, DartType type) {
148 if (expr is ParenthesizedExpression) { 143 if (expr is ParenthesizedExpression) {
149 checkAssignment(expr.expression, type); 144 checkAssignment(expr.expression, type);
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } while (!current.isObject && !visited.contains(current)); 1237 } while (!current.isObject && !visited.contains(current));
1243 } 1238 }
1244 1239
1245 void _recordMessage(StaticInfo info) { 1240 void _recordMessage(StaticInfo info) {
1246 if (info == null) return; 1241 if (info == null) return;
1247 var error = info.toAnalysisError(); 1242 var error = info.toAnalysisError();
1248 if (error.errorCode.errorSeverity == ErrorSeverity.ERROR) _failure = true; 1243 if (error.errorCode.errorSeverity == ErrorSeverity.ERROR) _failure = true;
1249 _reporter.onError(error); 1244 _reporter.onError(error);
1250 } 1245 }
1251 } 1246 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/static_type_analyzer.dart ('k') | pkg/analyzer/test/src/task/strong/checker_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698