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

Unified Diff: pkg/analyzer/test/generated/all_the_rest_test.dart

Issue 1705773002: Discard function elements created while building elements in annotations (issue 25696) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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/dart/element/builder.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/generated/all_the_rest_test.dart
diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart
index 3eb5cd096ae336a64212b07474f315d1cfbfdf46..b359c789ed9e5fba5eb851622c6a45fcfb6d1493 100644
--- a/pkg/analyzer/test/generated/all_the_rest_test.dart
+++ b/pkg/analyzer/test/generated/all_the_rest_test.dart
@@ -275,11 +275,19 @@ class ElementBuilderTest extends ParserTestCase {
* resulting [ElementHolder].
*/
ElementHolder buildElementsForText(String code) {
- compilationUnit = ParserTestCase.parseCompilationUnit(code);
- ElementHolder holder = new ElementHolder();
- ElementBuilder builder = new ElementBuilder(holder, compilationUnitElement);
- compilationUnit.accept(builder);
- return holder;
+ TestLogger logger = new TestLogger();
+ AnalysisEngine.instance.logger = logger;
+ try {
+ compilationUnit = ParserTestCase.parseCompilationUnit(code);
+ ElementHolder holder = new ElementHolder();
+ ElementBuilder builder =
+ new ElementBuilder(holder, compilationUnitElement);
+ compilationUnit.accept(builder);
+ return holder;
+ } finally {
+ expect(logger.log, hasLength(0));
+ AnalysisEngine.instance.logger = Logger.NULL;
+ }
}
/**
@@ -587,6 +595,38 @@ class C {
expect(type.isSynthetic, isFalse);
}
+ void test_visitClassDeclaration_invalidFunctionInAnnotation_class() {
+ // https://github.com/dart-lang/sdk/issues/25696
+ String code = r'''
+class A {
+ const A({f});
+}
+
+@A(f: () {})
+class C {}
+''';
+ buildElementsForText(code);
+ }
+
+ void test_visitClassDeclaration_invalidFunctionInAnnotation_method() {
+ String code = r'''
+class A {
+ const A({f});
+}
+
+class C {
+ @A(f: () {})
+ void m() {}
+}
+''';
+ ElementHolder holder = buildElementsForText(code);
+ ClassElement elementC = holder.types[1];
+ expect(elementC, isNotNull);
+ MethodElement methodM = elementC.methods[0];
+ expect(methodM, isNotNull);
+ expect(methodM.functions, isEmpty);
+ }
+
void test_visitClassDeclaration_minimal() {
ElementHolder holder = new ElementHolder();
ElementBuilder builder = _makeBuilder(holder);
« no previous file with comments | « pkg/analyzer/lib/src/dart/element/builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698