@@ -7,6 +7,7 @@ import 'dart:collection';
77import  'package:analyzer/dart/ast/ast.dart' ;
88import  'package:analyzer/dart/ast/visitor.dart' ;
99import  'package:analyzer/dart/element/element.dart' ;
10+ import  'package:analyzer/dart/element/type.dart' ;
1011import  'package:collection/collection.dart' ;
1112
1213import  '../analyzer.dart' ;
@@ -19,7 +20,7 @@ const _details = r'''
1920Top-level members in an executable library should be used directly inside this 
2021library.  An executable library is a library that contains a `main` top-level 
2122function or that contains a top-level function annotated with 
22- `@pragma('vm:entry-point')`).  Executable libraries are usually never  imported 
23+ `@pragma('vm:entry-point')`).  Executable libraries are not usually  imported 
2324and it's better to avoid defining unused members. 
2425
2526This rule assumes that an executable library isn't imported by other files 
@@ -168,10 +169,9 @@ class _Visitor extends SimpleAstVisitor<void> {
168169      (e.name.name ==  'main'  ||  e.metadata.any (_isPragmaVmEntry));
169170
170171  bool  _isPragmaVmEntry (Annotation  annotation) {
172+     if  (! annotation.isPragma) return  false ;
171173    var  value =  annotation.elementAnnotation? .computeConstantValue ();
172174    if  (value ==  null ) return  false ;
173-     var  element =  value.type? .element;
174-     if  (element ==  null  ||  ! element.isPragma) return  false ;
175175    var  name =  value.getField ('name' );
176176    return  name !=  null  && 
177177        name.hasKnownValue && 
@@ -182,3 +182,19 @@ class _Visitor extends SimpleAstVisitor<void> {
182182extension  on  Element  {
183183  bool  get  isPragma =>  (library? .isDartCore ??  false ) &&  name ==  'pragma' ;
184184}
185+ 
186+ extension  on  Annotation  {
187+   bool  get  isPragma {
188+     var  element =  elementAnnotation? .element;
189+     DartType  type;
190+     if  (element is  ConstructorElement ) {
191+       type =  element.returnType;
192+     } else  if  (element is  PropertyAccessorElement  &&  element.isGetter) {
193+       type =  element.returnType;
194+     } else  {
195+       // Dunno what this is. 
196+       return  false ;
197+     }
198+     return  type.element? .isPragma ??  false ;
199+   }
200+ }
0 commit comments