File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ import 'package:analyzer/dart/ast/ast.dart';
66
77/// An indication of the kind of context in which a super expression was found.
88class SuperContext {
9+ /// An indication that the super expression is in a context in which it is
10+ /// invalid because it is in an annotation.
11+ static const SuperContext annotation = SuperContext ._('annotation' );
12+
913 /// An indication that the super expression is in a context in which it is
1014 /// invalid because it is in an instance member of an extension.
1115 static const SuperContext extension = SuperContext ._('extension' );
@@ -25,7 +29,9 @@ class SuperContext {
2529 /// being used.
2630 factory SuperContext .of (SuperExpression expression) {
2731 for (AstNode node = expression; node != null ; node = node.parent) {
28- if (node is CompilationUnit ) {
32+ if (node is Annotation ) {
33+ return SuperContext .annotation;
34+ } else if (node is CompilationUnit ) {
2935 return SuperContext .static ;
3036 } else if (node is ConstructorDeclaration ) {
3137 return node.factoryKeyword == null
Original file line number Diff line number Diff line change @@ -224,6 +224,16 @@ part '${[for(var v = 0;;) v]}';
224224''' );
225225 }
226226
227+ test_fuzz_38878 () async {
228+ // We should not attempt to resolve `super` in annotations.
229+ await _assertCanBeAnalyzed (r'''
230+ class C {
231+ @A(super.f())
232+ f(int x) {}
233+ }
234+ ''' );
235+ }
236+
227237 test_genericFunction_asTypeArgument_ofUnresolvedClass () async {
228238 await _assertCanBeAnalyzed (r'''
229239C<int Function()> c;
You can’t perform that action at this time.
0 commit comments