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

Side by Side Diff: pkg/compiler/lib/src/resolution/constructors.dart

Issue 2118763002: Revert "Handle fields with initializers in constant constructors." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dart2js.resolution.constructors; 5 library dart2js.resolution.constructors;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show Feature; 8 import '../common/resolution.dart' show Feature;
9 import '../compiler.dart' show Compiler; 9 import '../compiler.dart' show Compiler;
10 import '../constants/constructors.dart' 10 import '../constants/constructors.dart'
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 return null; 441 return null;
442 } 442 }
443 } else { 443 } else {
444 reporter.reportErrorMessage(link.head, MessageKind.INVALID_INITIALIZER); 444 reporter.reportErrorMessage(link.head, MessageKind.INVALID_INITIALIZER);
445 } 445 }
446 } 446 }
447 if (!resolvedSuper) { 447 if (!resolvedSuper) {
448 constructorInvocation = resolveImplicitSuperConstructorSend(); 448 constructorInvocation = resolveImplicitSuperConstructorSend();
449 } 449 }
450 if (isConst && isValidAsConstant) { 450 if (isConst && isValidAsConstant) {
451 constructor.enclosingClass.forEachInstanceField((_, FieldElement field) { 451 constructor.constantConstructor = new GenerativeConstantConstructor(
452 if (!fieldInitializers.containsKey(field)) { 452 constructor.enclosingClass.thisType,
453 visitor.resolution.ensureResolved(field); 453 defaultValues,
454 // TODO(johnniwinther): Report error if `field.constant` is `null`. 454 fieldInitializers,
455 if (field.constant != null) { 455 constructorInvocation);
456 fieldInitializers[field] = field.constant;
457 } else {
458 isValidAsConstant = false;
459 }
460 }
461 });
462 if (isValidAsConstant) {
463 constructor.constantConstructor = new GenerativeConstantConstructor(
464 constructor.enclosingClass.thisType,
465 defaultValues,
466 fieldInitializers,
467 constructorInvocation);
468 }
469 } 456 }
470 visitor.scope = oldScope; 457 visitor.scope = oldScope;
471 return null; // If there was no redirection always return null. 458 return null; // If there was no redirection always return null.
472 } 459 }
473 } 460 }
474 461
475 class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> { 462 class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> {
476 final ResolverVisitor resolver; 463 final ResolverVisitor resolver;
477 final bool inConstContext; 464 final bool inConstContext;
478 465
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 // constructors. 875 // constructors.
889 return null; 876 return null;
890 } 877 }
891 // TODO(johnniwinther): Use [Name] for lookup. 878 // TODO(johnniwinther): Use [Name] for lookup.
892 ConstructorElement constructor = cls.lookupConstructor(constructorName); 879 ConstructorElement constructor = cls.lookupConstructor(constructorName);
893 if (constructor != null) { 880 if (constructor != null) {
894 constructor = constructor.declaration; 881 constructor = constructor.declaration;
895 } 882 }
896 return constructor; 883 return constructor;
897 } 884 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart ('k') | pkg/compiler/lib/src/resolution/resolution.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698