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

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

Issue 2392303002: Handle invalid default cases. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « no previous file | no next file » | 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 library dart2js.resolution.members; 5 library dart2js.resolution.members;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/names.dart' show Selectors; 8 import '../common/names.dart' show Selectors;
9 import '../common/resolution.dart' show Resolution; 9 import '../common/resolution.dart' show Resolution;
10 import '../compile_time_constants.dart'; 10 import '../compile_time_constants.dart';
(...skipping 4584 matching lines...) Expand 10 before | Expand all | Expand 10 after
4595 LabelDefinition labelElement = targetElement.addLabel(label, labelName); 4595 LabelDefinition labelElement = targetElement.addLabel(label, labelName);
4596 registry.defineLabel(label, labelElement); 4596 registry.defineLabel(label, labelElement);
4597 continueLabels[labelName] = labelElement; 4597 continueLabels[labelName] = labelElement;
4598 } 4598 }
4599 cases = cases.tail; 4599 cases = cases.tail;
4600 // Test that only the last case, if any, is a default case. 4600 // Test that only the last case, if any, is a default case.
4601 if (switchCase.defaultKeyword != null && !cases.isEmpty) { 4601 if (switchCase.defaultKeyword != null && !cases.isEmpty) {
4602 reporter.reportErrorMessage( 4602 reporter.reportErrorMessage(
4603 switchCase, MessageKind.INVALID_CASE_DEFAULT); 4603 switchCase, MessageKind.INVALID_CASE_DEFAULT);
4604 } 4604 }
4605 if (cases.isNotEmpty) { 4605 if (cases.isNotEmpty && switchCase.statements.isNotEmpty) {
4606 Node last = switchCase.statements.last; 4606 Node last = switchCase.statements.last;
4607 if (last.asBreakStatement() == null && 4607 if (last.asBreakStatement() == null &&
4608 last.asContinueStatement() == null && 4608 last.asContinueStatement() == null &&
4609 last.asThrow() == null && 4609 last.asThrow() == null &&
4610 last.asReturn() == null) { 4610 last.asReturn() == null) {
4611 registry.registerFeature(Feature.FALL_THROUGH_ERROR); 4611 registry.registerFeature(Feature.FALL_THROUGH_ERROR);
4612 } 4612 }
4613 } 4613 }
4614 } 4614 }
4615 4615
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
4740 } 4740 }
4741 return const NoneResult(); 4741 return const NoneResult();
4742 } 4742 }
4743 } 4743 }
4744 4744
4745 /// Looks up [name] in [scope] and unwraps the result. 4745 /// Looks up [name] in [scope] and unwraps the result.
4746 Element lookupInScope( 4746 Element lookupInScope(
4747 DiagnosticReporter reporter, Node node, Scope scope, String name) { 4747 DiagnosticReporter reporter, Node node, Scope scope, String name) {
4748 return Elements.unwrap(scope.lookup(name), reporter, node); 4748 return Elements.unwrap(scope.lookup(name), reporter, node);
4749 } 4749 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698