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

Unified Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1156893006: Fix NPE when computing dependencies of enum constants (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/dart_test.dart
diff --git a/pkg/analyzer/test/src/task/dart_test.dart b/pkg/analyzer/test/src/task/dart_test.dart
index d5abbbfe8001568d2d2b27c7a030fcbc8f6ca8b2..531b82590becb76b935fbc05ae7919a60c6e755e 100644
--- a/pkg/analyzer/test/src/task/dart_test.dart
+++ b/pkg/analyzer/test/src/task/dart_test.dart
@@ -1289,6 +1289,25 @@ const x = 1;
expect(outputs[CONSTANT_DEPENDENCIES], [x]);
}
+ test_enumConstant() {
+ Source source = newSource('/test.dart', '''
+enum E {A, B, C}
+''');
+ // First compute the resolved unit for the source.
+ LibrarySpecificUnit librarySpecificUnit =
+ new LibrarySpecificUnit(source, source);
+ _computeResult(librarySpecificUnit, RESOLVED_UNIT2);
+ CompilationUnit unit = outputs[RESOLVED_UNIT2];
+ // Find the element for 'A'
+ EnumDeclaration enumDeclaration = unit.declarations[0];
+ EnumConstantDeclaration constantDeclaration = enumDeclaration.constants[0];
+ FieldElement constantElement = constantDeclaration.element;
+ // Now compute the dependencies for the constant and check that there are
+ // none.
+ _computeResult(constantElement, CONSTANT_DEPENDENCIES);
+ expect(outputs[CONSTANT_DEPENDENCIES], isEmpty);
+ }
+
test_perform() {
Source source = newSource('/test.dart', '''
const x = y;
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698