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

Unified Diff: pkg/compiler/lib/src/resolution/constructors.dart

Issue 2104843002: Handle fields with initializers in constant constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix invariants. Created 4 years, 6 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/js_backend/backend.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/resolution/constructors.dart
diff --git a/pkg/compiler/lib/src/resolution/constructors.dart b/pkg/compiler/lib/src/resolution/constructors.dart
index e30cfdcd7e496a70befa528d5db98275db08b9fc..90f471633992735dbb78284087be70a589fa56e6 100644
--- a/pkg/compiler/lib/src/resolution/constructors.dart
+++ b/pkg/compiler/lib/src/resolution/constructors.dart
@@ -448,11 +448,24 @@ class InitializerResolver {
constructorInvocation = resolveImplicitSuperConstructorSend();
}
if (isConst && isValidAsConstant) {
- constructor.constantConstructor = new GenerativeConstantConstructor(
- constructor.enclosingClass.thisType,
- defaultValues,
- fieldInitializers,
- constructorInvocation);
+ constructor.enclosingClass.forEachInstanceField((_, FieldElement field) {
+ if (!fieldInitializers.containsKey(field)) {
+ visitor.resolution.ensureResolved(field);
+ // TODO(johnniwinther): Report error if `field.constant` is `null`.
+ if (field.constant != null) {
+ fieldInitializers[field] = field.constant;
+ } else {
+ isValidAsConstant = false;
+ }
+ }
+ });
+ if (isValidAsConstant) {
+ constructor.constantConstructor = new GenerativeConstantConstructor(
+ constructor.enclosingClass.thisType,
+ defaultValues,
+ fieldInitializers,
+ constructorInvocation);
+ }
}
visitor.scope = oldScope;
return null; // If there was no redirection always return null.
« no previous file with comments | « pkg/compiler/lib/src/js_backend/backend.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698