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

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

Issue 2767103003: Fix #29130: only consider classes allocated with generative constructors as potential closures (Closed)
Patch Set: Created 3 years, 9 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 | tests/compiler/dart2js_extra/29130_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/inferrer/inferrer_engine.dart
diff --git a/pkg/compiler/lib/src/inferrer/inferrer_engine.dart b/pkg/compiler/lib/src/inferrer/inferrer_engine.dart
index 8b06eac0732f2bbacb5b3004d3f642c50b86d55a..e91a884b004a2f3b14c173578f1e5ccac30bca8e 100644
--- a/pkg/compiler/lib/src/inferrer/inferrer_engine.dart
+++ b/pkg/compiler/lib/src/inferrer/inferrer_engine.dart
@@ -382,7 +382,7 @@ class InferrerEngine {
info.selector.isCall) {
// This is a constructor call to a class with a call method. So we
// need to trace the call method here.
- assert(info.calledElement.isConstructor);
+ assert(info.calledElement.isGenerativeConstructor);
ClassElement cls = info.calledElement.enclosingClass;
FunctionElement callMethod = cls.lookupMember(Identifiers.call);
assert(invariant(cls, callMethod != null));
@@ -844,7 +844,10 @@ class InferrerEngine {
inLoop);
// If this class has a 'call' method then we have essentially created a
// closure here. Register it as such so that it is traced.
- if (selector != null && selector.isCall && callee.isConstructor) {
+ // Note: we exclude factory constructors because they don't always create an
+ // instance of the type. They are static methods that delegate to some other
+ // generative constructor to do the actual creation of the object.
+ if (selector != null && selector.isCall && callee.isGenerativeConstructor) {
ClassElement cls = callee.enclosingClass;
if (cls.callType != null) {
types.allocatedClosures.add(info);
« no previous file with comments | « no previous file | tests/compiler/dart2js_extra/29130_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698