Chromium Code Reviews| 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 43d6813adf6a411fbd7cb9d454da1998b82675cb..174ca8a5be9af9e4a9135cf62411111235c421d2 100644 |
| --- a/compiler/java/com/google/dart/compiler/type/Types.java |
| +++ b/compiler/java/com/google/dart/compiler/type/Types.java |
| @@ -355,6 +355,27 @@ public class Types { |
| return false; |
| } |
| } |
| + |
| + { |
| + Map<String, Type> sOpti = s.getOptionalParameterTypes(); |
| + Map<String, Type> tOpti = t.getOptionalParameterTypes(); |
| + if (tOpti.size() < sOpti.size()) { |
| + return false; |
| + } |
| + Iterator<Entry<String, Type>> tList = tOpti.entrySet().iterator(); |
| + Iterator<Entry<String, Type>> sList = sOpti.entrySet().iterator(); |
| + while (sList.hasNext()) { |
| + if (!tList.hasNext()) { |
| + return false; |
| + } |
| + Entry<String, Type> sEntry = sList.next(); |
| + Entry<String, Type> tEntry = tList.next(); |
| + if (!isAssignable(tEntry.getValue(), sEntry.getValue())) { |
| + return false; |
| + } |
| + } |
| + } |
| + |
| Map<String, Type> tNamed = t.getNamedParameterTypes(); |
| Map<String, Type> sNamed = s.getNamedParameterTypes(); |
| if (tNamed.isEmpty() && !sNamed.isEmpty()) { |
| @@ -366,23 +387,34 @@ public class Types { |
| if (!sNamed.isEmpty()) { |
| LinkedHashMap<String,Type> tMap = (LinkedHashMap<String, Type>)(tNamed); |
| LinkedHashMap<String,Type> sMap = (LinkedHashMap<String, Type>)(sNamed); |
| - Iterator<Entry<String, Type>> tList = tMap.entrySet().iterator(); |
| - Iterator<Entry<String, Type>> sList = sMap.entrySet().iterator(); |
| - // t named parameters must start with the named parameters of s |
| - while (sList.hasNext()) { |
| - if (!tList.hasNext()) { |
| - return false; |
| - } |
| - Entry<String, Type> sEntry = sList.next(); |
| - Entry<String, Type> tEntry = tList.next(); |
| - if (!sEntry.getKey().equals(tEntry.getKey())) { |
| - return false; |
| - } |
| - // Classic: parameter types are contravariant; Dart: assignable. |
| - if (!isAssignable(tEntry.getValue(), sEntry.getValue())) { |
| + if (!tMap.keySet().containsAll(sMap.keySet())) { |
| + return false; |
| + } |
| + for (Entry<String, Type> entry : sMap.entrySet()) { |
| + String name = entry.getKey(); |
| + Type sType = sMap.get(name); |
| + Type tType = tMap.get(name); |
| + if (!isAssignable(tType, sType)) { |
| return false; |
| } |
| } |
| +// Iterator<Entry<String, Type>> tList = tMap.entrySet().iterator(); |
|
Brian Wilkerson
2012/10/27 00:09:39
Is there any reason not to delete the commented ou
|
| +// Iterator<Entry<String, Type>> sList = sMap.entrySet().iterator(); |
| +// // t named parameters must start with the named parameters of s |
| +// while (sList.hasNext()) { |
| +// if (!tList.hasNext()) { |
| +// return false; |
| +// } |
| +// Entry<String, Type> sEntry = sList.next(); |
| +// Entry<String, Type> tEntry = tList.next(); |
| +// if (!sEntry.getKey().equals(tEntry.getKey())) { |
| +// return false; |
| +// } |
| +// // Classic: parameter types are contravariant; Dart: assignable. |
| +// if (!isAssignable(tEntry.getValue(), sEntry.getValue())) { |
| +// return false; |
| +// } |
| +// } |
| } |
| // Classic: parameter types are contravariant; Dart: assignable. |