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

Unified Diff: lib/type_checker.dart

Issue 2504313002: Fix some issues after introducing NamedType. (Closed)
Patch Set: Update testcase to cover the missing case Created 4 years, 1 month 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 | « lib/type_algebra.dart ('k') | testcases/input/named_parameters.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/type_checker.dart
diff --git a/lib/type_checker.dart b/lib/type_checker.dart
index be49ca0c285c5a8943374170ef6a0d54fc76bf8d..ab0351eb40b59ace8f18901b52027ecb27e0d356 100644
--- a/lib/type_checker.dart
+++ b/lib/type_checker.dart
@@ -471,12 +471,20 @@ class TypeCheckingVisitor
}
for (int i = 0; i < arguments.named.length; ++i) {
var argument = arguments.named[i];
- var expectedType = function.namedParameters[argument.name];
- if (expectedType == null) {
+ bool found = false;
+ for (int j = 0; j < function.namedParameters.length; ++j) {
+ if (argument.name == function.namedParameters[j].name) {
+ var expectedType = instantiation.substituteType(
+ function.namedParameters[j].type,
+ contravariant: true);
+ checkAssignableExpression(argument.value, expectedType);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
fail(argument.value, 'Unexpected named parameter: ${argument.name}');
- } else {
- checkAssignableExpression(argument.value,
- instantiation.substituteType(expectedType, contravariant: true));
+ return const BottomType();
}
}
return instantiation.substituteType(function.returnType);
« no previous file with comments | « lib/type_algebra.dart ('k') | testcases/input/named_parameters.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698