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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 25504002: Emit a compile-time error for uninitialized final variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element get currentElement; 8 Element get currentElement;
9 Set<Node> get superUses; 9 Set<Node> get superUses;
10 10
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 TreeElements resolveField(VariableElement element) { 442 TreeElements resolveField(VariableElement element) {
443 Node tree = element.parseNode(compiler); 443 Node tree = element.parseNode(compiler);
444 if(element.modifiers.isStatic() && element.variables.isTopLevel()) { 444 if(element.modifiers.isStatic() && element.variables.isTopLevel()) {
445 error(element.modifiers.getStatic(), 445 error(element.modifiers.getStatic(),
446 MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC); 446 MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC);
447 } 447 }
448 ResolverVisitor visitor = visitorFor(element); 448 ResolverVisitor visitor = visitorFor(element);
449 visitor.useElement(tree, element); 449 visitor.useElement(tree, element);
450 450
451 SendSet send = tree.asSendSet(); 451 SendSet send = tree.asSendSet();
452 Modifiers modifiers = element.modifiers;
452 if (send != null) { 453 if (send != null) {
453 // TODO(johnniwinther): Avoid analyzing initializers if 454 // TODO(johnniwinther): Avoid analyzing initializers if
454 // [Compiler.analyzeSignaturesOnly] is set. 455 // [Compiler.analyzeSignaturesOnly] is set.
455 visitor.visit(send.arguments.head); 456 visitor.visit(send.arguments.head);
456 } else if (element.modifiers.isConst()) { 457 } else if (modifiers.isConst()) {
457 compiler.reportError(element, MessageKind.CONST_WITHOUT_INITIALIZER); 458 compiler.reportError(element, MessageKind.CONST_WITHOUT_INITIALIZER);
459 } else if (modifiers.isStatic() && modifiers.isFinal()) {
460 compiler.reportError(element,
kasperl 2013/10/02 12:17:02 Shouldn't this be a warning?
461 MessageKind.STATIC_FINAL_WITHOUT_INITIALIZER);
458 } 462 }
459 463
460 if (Elements.isStaticOrTopLevelField(element)) { 464 if (Elements.isStaticOrTopLevelField(element)) {
461 if (tree.asSendSet() != null) { 465 if (tree.asSendSet() != null) {
462 // TODO(13429): We could do better here by using the 466 // TODO(13429): We could do better here by using the
463 // constant handler to figure out if it's a lazy field or not. 467 // constant handler to figure out if it's a lazy field or not.
464 compiler.backend.registerLazyField(visitor.mapping); 468 compiler.backend.registerLazyField(visitor.mapping);
465 } else { 469 } else {
466 compiler.enqueuer.resolution.registerInstantiatedClass( 470 compiler.enqueuer.resolution.registerInstantiatedClass(
467 compiler.nullClass, visitor.mapping); 471 compiler.nullClass, visitor.mapping);
(...skipping 3952 matching lines...) Expand 10 before | Expand all | Expand 10 after
4420 return e; 4424 return e;
4421 } 4425 }
4422 4426
4423 /// Assumed to be called by [resolveRedirectingFactory]. 4427 /// Assumed to be called by [resolveRedirectingFactory].
4424 Element visitReturn(Return node) { 4428 Element visitReturn(Return node) {
4425 Node expression = node.expression; 4429 Node expression = node.expression;
4426 return finishConstructorReference(visit(expression), 4430 return finishConstructorReference(visit(expression),
4427 expression, expression); 4431 expression, expression);
4428 } 4432 }
4429 } 4433 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/warnings.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698