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

Unified Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1129693006: Fix field initialization order for forwarding constructors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 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: pkg/compiler/lib/src/ssa/builder.dart
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index 2dca5031067a69d05063bccad4a974cf8654d439..bdbb88b7c43e3a3e8f26648133c9fe768256e646 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -1827,7 +1827,7 @@ class SsaBuilder extends NewResolvedVisitor {
*
* Invariant: [constructors] must contain only implementation elements.
*/
- void inlineSuperOrRedirect(FunctionElement callee,
+ void inlineSuperOrRedirect(ConstructorElement callee,
List<HInstruction> compiledArguments,
List<FunctionElement> constructors,
Map<Element, HInstruction> fieldValues,
@@ -1869,9 +1869,9 @@ class SsaBuilder extends NewResolvedVisitor {
}
}
- // For redirecting constructors, the fields have already been
- // initialized by the caller.
- if (callee.enclosingClass != caller.enclosingClass) {
+ // For redirecting constructors, the fields will be initialized later
+ // by the effective target.
+ if (!callee.isRedirectingGenerative) {
inlinedFrom(callee, () {
buildFieldInitializers(callee.enclosingElement.implementation,
fieldValues);
@@ -2074,7 +2074,7 @@ class SsaBuilder extends NewResolvedVisitor {
* - Call the constructor bodies, starting from the constructor(s) in the
* super class(es).
*/
- HGraph buildFactory(FunctionElement functionElement) {
+ HGraph buildFactory(ConstructorElement functionElement) {
functionElement = functionElement.implementation;
ClassElement classElement =
functionElement.enclosingClass.implementation;
@@ -2093,8 +2093,11 @@ class SsaBuilder extends NewResolvedVisitor {
Map<Element, HInstruction> fieldValues = new Map<Element, HInstruction>();
// Compile the possible initialization code for local fields and
- // super fields.
- buildFieldInitializers(classElement, fieldValues);
+ // super fields, unless this is a redirecting constructor, in which case
+ // the effective target will initialize these.
+ if (!functionElement.isRedirectingGenerative) {
+ buildFieldInitializers(classElement, fieldValues);
+ }
// Compile field-parameters such as [:this.x:].
FunctionSignature params = functionElement.functionSignature;

Powered by Google App Engine
This is Rietveld 408576698