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

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

Issue 2607013003: Some constructor fixes: implement redirecting constructors, work with finding default constructors … (Closed)
Patch Set: . Created 4 years 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/kernel/constructors_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/ssa/builder_kernel.dart
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 4dabdefd8bebe4ce7f2035f5e583f95dcf80f901..1632df56432ff69c2492cf15015dc95d671420a4 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -308,15 +308,16 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
/// Collects field initializers all the way up the inheritance chain.
void _buildInitializers(
ir.Constructor constructor, Map<ir.Field, HInstruction> fieldValues) {
- var foundSuperCall = false;
+ var foundSuperOrRedirectCall = false;
for (var initializer in constructor.initializers) {
- if (initializer is ir.SuperInitializer) {
- foundSuperCall = true;
- var superConstructor = initializer.target;
+ if (initializer is ir.SuperInitializer ||
+ initializer is ir.RedirectingInitializer) {
+ foundSuperOrRedirectCall = true;
+ var superOrRedirectConstructor = initializer.target;
var arguments = _normalizeAndBuildArguments(
- superConstructor.function, initializer.arguments);
+ superOrRedirectConstructor.function, initializer.arguments);
_buildInlinedSuperInitializers(
Siggi Cherem (dart-lang) 2016/12/29 23:28:33 I wonder if we should rename this function. Some i
Emily Fortuna 2016/12/29 23:42:44 good point. I changed to _buildInlinedInitializer
- superConstructor, arguments, fieldValues);
+ superOrRedirectConstructor, arguments, fieldValues);
} else if (initializer is ir.FieldInitializer) {
initializer.value.accept(this);
fieldValues[initializer.field] = pop();
@@ -326,11 +327,11 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
// TODO(het): does kernel always set the super initializer at the end?
// If there was no super-call initializer, then call the default constructor
// in the superclass.
- if (!foundSuperCall) {
+ if (!foundSuperOrRedirectCall) {
Siggi Cherem (dart-lang) 2016/12/29 23:28:32 consider updating the comment above this? I belie
Emily Fortuna 2016/12/29 23:42:44 Correct. and good catch on the comment. updated!
if (constructor.enclosingClass != astAdapter.objectClass) {
var superclass = constructor.enclosingClass.superclass;
var defaultConstructor = superclass.constructors
- .firstWhere((c) => c.name == '', orElse: () => null);
+ .firstWhere((c) => c.name.name == '', orElse: () => null);
if (defaultConstructor == null) {
compiler.reporter.internalError(
NO_LOCATION_SPANNABLE, 'Could not find default constructor.');
@@ -1198,7 +1199,8 @@ class KernelSsaBuilder extends ir.Visitor with GraphBuilder {
// If runtime type information is needed and the map literal has no type
// parameters, 'constructor' is a static function that forwards the call to
// the factory constructor without type parameters.
- assert(constructor.kind == ir.ProcedureKind.Factory);
+ assert(constructor.kind == ir.ProcedureKind.Method
+ || constructor.kind == ir.ProcedureKind.Factory);
// The instruction type will always be a subtype of the mapLiteralClass, but
// type inference might discover a more specific type, or find nothing (in
« no previous file with comments | « no previous file | tests/compiler/dart2js/kernel/constructors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698