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

Unified Diff: pkg/compiler/lib/src/inferrer/type_graph_nodes.dart

Issue 1355563002: Abandon type inference on closures that (potentially) flow into Function.apply. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 | « pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart ('k') | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
diff --git a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
index 900bd4796113c2e5f59a81b87b6b6ee86f0134fe..9b2123e0029452d13dddd8c7d5cb58c47f3328e3 100644
--- a/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
+++ b/pkg/compiler/lib/src/inferrer/type_graph_nodes.dart
@@ -88,6 +88,10 @@ abstract class TypeInformation {
users.add(user);
}
+ void addUsersOf(TypeInformation other) {
+ users.addAll(other.users);
+ }
+
void removeUser(TypeInformation user) {
assert(!user.isConcrete);
users.remove(user);
@@ -524,6 +528,10 @@ class ParameterTypeInformation extends ElementTypeInformation {
void tagAsTearOffClosureParameter(TypeGraphInferrerEngine inferrer) {
assert(element.isParameter);
isTearOffClosureParameter = true;
+ // We have to add a flow-edge for the default value (if it exists), as we
+ // might not see all call-sites and thus miss the use of it.
+ TypeInformation defaultType = inferrer.getDefaultTypeOfParameter(element);
+ if (defaultType != null) defaultType.addUser(this);
}
// TODO(herhut): Cleanup into one conditional.
@@ -540,8 +548,7 @@ class ParameterTypeInformation extends ElementTypeInformation {
// initializing formals.
if (element.isInitializingFormal) return null;
- FunctionElement function = element.functionDeclaration;
- if ((isTearOffClosureParameter || function.isLocal) &&
+ if ((isTearOffClosureParameter || declaration.isLocal) &&
disableInferenceForClosures) {
// Do not infer types for parameters of closures. We do not
// clear the assignments in case the closure is successfully
@@ -549,16 +556,20 @@ class ParameterTypeInformation extends ElementTypeInformation {
giveUp(inferrer, clearAssignments: false);
return safeType(inferrer);
}
- if (function.isInstanceMember &&
- (function.name == Identifiers.noSuchMethod_ ||
- (function.name == Identifiers.call &&
+ if (declaration.isInstanceMember &&
+ (declaration.name == Identifiers.noSuchMethod_ ||
+ (declaration.name == Identifiers.call &&
disableInferenceForClosures))) {
// Do not infer types for parameters of [noSuchMethod] and
// [call] instance methods.
giveUp(inferrer);
return safeType(inferrer);
}
- if (function == inferrer.mainElement) {
+ if (inferrer.compiler.world.getMightBePassedToApply(declaration)) {
+ giveUp(inferrer);
+ return safeType(inferrer);
+ }
+ if (declaration == inferrer.mainElement) {
// The implicit call to main is not seen by the inferrer,
// therefore we explicitly set the type of its parameters as
// dynamic.
@@ -1070,6 +1081,11 @@ class ConcreteTypeInformation extends TypeInformation {
// needs to notify its users.
}
+ void addUsersOf(TypeInformation other) {
+ // Nothing to do, a concrete type does not get updated so never
+ // needs to notify its users.
+ }
+
void removeUser(TypeInformation user) {
}
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart ('k') | tests/compiler/dart2js/dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698