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

Unified Diff: compiler/java/com/google/dart/compiler/type/Types.java

Issue 10828355: Issue 4289. Test that arguments are bound to positional, optional and named parameters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Prepare for making optional parameter not named Created 8 years, 4 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
Index: compiler/java/com/google/dart/compiler/type/Types.java
diff --git a/compiler/java/com/google/dart/compiler/type/Types.java b/compiler/java/com/google/dart/compiler/type/Types.java
index 0c2dad12f8b250d37234edbdaa68e2bc2db6dbb4..0964dfdc15c8ae1dd8a88bffae272437931c5303 100644
--- a/compiler/java/com/google/dart/compiler/type/Types.java
+++ b/compiler/java/com/google/dart/compiler/type/Types.java
@@ -428,21 +428,29 @@ public class Types {
List<VariableElement> parameters,
Type returnType) {
List<Type> parameterTypes = new ArrayList<Type>(parameters.size());
+ Map<String, Type> optionalParameterTypes = null;
Map<String, Type> namedParameterTypes = null;
Type restParameter = null;
for (VariableElement parameter : parameters) {
Type type = parameter.getType();
+ // TODO(scheglov) one we will make optional parameter not named,
+ // check isOptional() before isNamed()
if (parameter.isNamed()) {
if (namedParameterTypes == null) {
namedParameterTypes = new LinkedHashMap<String, Type>();
}
namedParameterTypes.put(parameter.getName(), type);
+ } else if (parameter.isOptional()) {
+ if (optionalParameterTypes == null) {
+ optionalParameterTypes = new LinkedHashMap<String, Type>();
+ }
+ optionalParameterTypes.put(parameter.getName(), type);
} else {
parameterTypes.add(type);
}
}
- return FunctionTypeImplementation.of(element, parameterTypes, namedParameterTypes,
- restParameter, returnType);
+ return FunctionTypeImplementation.of(element, parameterTypes, optionalParameterTypes,
+ namedParameterTypes, restParameter, returnType);
}
public static Types getInstance(CoreTypeProvider typeProvider) {

Powered by Google App Engine
This is Rietveld 408576698