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

Side by Side Diff: pkg/analyzer/lib/src/dart/constant/utilities.dart

Issue 1958433002: Do not fail when an enum constant is annotated (issue 26413) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 | pkg/analyzer/test/src/dart/constant/utilities_test.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 analyzer.src.dart.constant.utilities; 5 library analyzer.src.dart.constant.utilities;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/visitor.dart'; 10 import 'package:analyzer/dart/ast/visitor.dart';
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 */ 165 */
166 bool treatFinalInstanceVarAsConst = false; 166 bool treatFinalInstanceVarAsConst = false;
167 167
168 ConstantFinder(this.context, this.source, this.librarySource); 168 ConstantFinder(this.context, this.source, this.librarySource);
169 169
170 @override 170 @override
171 Object visitAnnotation(Annotation node) { 171 Object visitAnnotation(Annotation node) {
172 super.visitAnnotation(node); 172 super.visitAnnotation(node);
173 ElementAnnotation elementAnnotation = node.elementAnnotation; 173 ElementAnnotation elementAnnotation = node.elementAnnotation;
174 if (elementAnnotation == null) { 174 if (elementAnnotation == null) {
175 // Analyzer ignores annotations on "part of" directives. 175 // Analyzer ignores annotations on "part of" directives and on enum
176 assert(node.parent is PartOfDirective); 176 // constant declarations.
177 assert(node.parent is PartOfDirective ||
178 node.parent is EnumConstantDeclaration);
177 } else { 179 } else {
178 constantsToCompute.add(elementAnnotation); 180 constantsToCompute.add(elementAnnotation);
179 } 181 }
180 return null; 182 return null;
181 } 183 }
182 184
183 @override 185 @override
184 Object visitClassDeclaration(ClassDeclaration node) { 186 Object visitClassDeclaration(ClassDeclaration node) {
185 bool prevTreatFinalInstanceVarAsConst = treatFinalInstanceVarAsConst; 187 bool prevTreatFinalInstanceVarAsConst = treatFinalInstanceVarAsConst;
186 if (node.element.constructors.any((ConstructorElement e) => e.isConst)) { 188 if (node.element.constructors.any((ConstructorElement e) => e.isConst)) {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 @override 305 @override
304 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) { 306 Object visitSuperConstructorInvocation(SuperConstructorInvocation node) {
305 super.visitSuperConstructorInvocation(node); 307 super.visitSuperConstructorInvocation(node);
306 ConstructorElement constructor = getConstructorImpl(node.staticElement); 308 ConstructorElement constructor = getConstructorImpl(node.staticElement);
307 if (constructor != null) { 309 if (constructor != null) {
308 _callback(constructor); 310 _callback(constructor);
309 } 311 }
310 return null; 312 return null;
311 } 313 }
312 } 314 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/constant/utilities_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698