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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java

Issue 599293002: Implement strict and non-strict union types behind flag [strictUnionTypes]. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address @brianwilkerson comments. Created 6 years, 3 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
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/type/FunctionTypeImpl.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java
index 5a8367063c077951cf1ba62c317753e2cdea3a5a..cace1bfe42328615a091eab17b08eff34263611e 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ElementResolver.java
@@ -122,6 +122,7 @@ import com.google.dart.engine.type.UnionType;
import com.google.dart.engine.utilities.dart.ParameterKind;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
@@ -2244,13 +2245,25 @@ public class ElementResolver extends SimpleAstVisitor<Void> {
*/
private Set<ExecutableElement> lookupMethods(Expression target, UnionType type, String methodName) {
Set<ExecutableElement> methods = new HashSet<ExecutableElement>();
+ boolean allElementsHaveMethod = true;
for (Type t : type.getElements()) {
MethodElement m = lookUpMethod(target, t, methodName);
if (m != null) {
methods.add(m);
+ } else {
+ allElementsHaveMethod = false;
}
}
- return methods;
+ // For strict union types we require that all types in the union define the method.
+ if (AnalysisEngine.getInstance().getStrictUnionTypes()) {
+ if (allElementsHaveMethod) {
+ return methods;
+ } else {
+ return Collections.emptySet();
+ }
+ } else {
+ return methods;
+ }
}
/**
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/type/FunctionTypeImpl.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698