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

Unified Diff: lib/compiler/implementation/resolver.dart

Issue 10834327: Produce error when duplicate field initializers are found (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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/co19/co19-leg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/resolver.dart
diff --git a/lib/compiler/implementation/resolver.dart b/lib/compiler/implementation/resolver.dart
index aff2ad7514ac706518559708544f85e8f670c237..913abdb0432ead0f285ad3b0e53de659b21f2959 100644
--- a/lib/compiler/implementation/resolver.dart
+++ b/lib/compiler/implementation/resolver.dart
@@ -128,7 +128,8 @@ class ResolverTask extends CompilerTask {
if (isConstructor) {
// Even if there is no initializer list we still have to do the
// resolution in case there is an implicit super constructor call.
- InitializerResolver resolver = new InitializerResolver(visitor);
+ InitializerResolver resolver =
+ new InitializerResolver(compiler, visitor);
FunctionElement redirection =
resolver.resolveInitializers(element, tree);
if (redirection !== null) {
@@ -406,12 +407,13 @@ class ResolverTask extends CompilerTask {
}
class InitializerResolver {
+ final Compiler compiler;
ahe 2012/08/15 10:47:07 Don't need this field.
final ResolverVisitor visitor;
final Map<SourceString, Node> initialized;
Link<Node> initializers;
bool hasSuper;
- InitializerResolver(this.visitor)
+ InitializerResolver(this.compiler, this.visitor)
: initialized = new Map<SourceString, Node>(), hasSuper = false;
error(Node node, MessageKind kind, [arguments = const []]) {
@@ -552,6 +554,18 @@ class InitializerResolver {
*/
FunctionElement resolveInitializers(FunctionElement constructor,
FunctionExpression functionNode) {
+ // keep track of all "this.param" parameters specified for constructor so
ahe 2012/08/15 10:47:07 Not a proper sentence. By which I mean: please cap
+ // that we can ensure that fields are initialized only once
+ FunctionSignature functionParameters =
+ constructor.computeSignature(compiler);
ahe 2012/08/15 10:47:07 You can get this from visitor.compiler.
+ if (functionParameters != null) {
+ functionParameters.forEachParameter((Element element) {
+ if (element.kind == ElementKind.FIELD_PARAMETER) {
+ initialized[element.name] = element;
+ }
+ });
+ }
+
if (functionNode.initializers === null) {
initializers = const EmptyLink<Node>();
} else {
« no previous file with comments | « no previous file | tests/co19/co19-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698