@@ -492,10 +492,15 @@ class StructAnnotations(ParsedAnnotations):
492
492
class FunAnnotations (ParsedAnnotations ):
493
493
abstract : bool
494
494
export : bool
495
+ external : bool
496
+ uses_entity_info : bool
497
+ uses_envs : bool
495
498
annotations = [
496
499
FlagAnnotationSpec ('abstract' ),
497
-
498
500
FlagAnnotationSpec ('export' ),
501
+ FlagAnnotationSpec ('external' ),
502
+ FlagAnnotationSpec ('uses_entity_info' ),
503
+ FlagAnnotationSpec ('uses_envs' ),
499
504
]
500
505
501
506
@@ -1665,12 +1670,25 @@ def lower_property(self, full_decl: L.FullDecl) -> PropertyDef:
1665
1670
env [a ] = arg .var
1666
1671
1667
1672
# Lower the expression itself
1668
- if annotations .abstract :
1673
+ if annotations .abstract or annotations . external :
1669
1674
assert decl .f_body is None
1670
1675
expr = None
1671
1676
else :
1672
1677
expr = self .lower_expr (decl .f_body , env )
1673
1678
1679
+ # If @uses_entity_info and @uses_envs are not present for non-external
1680
+ # properties, use None instead of False, for the validation machinery
1681
+ # in PropertyDef to work properly (we expect False/true for external
1682
+ # properties, and None for non-external ones).
1683
+ uses_entity_info : Optional [bool ]
1684
+ uses_envs : Optional [bool ]
1685
+ if annotations .external :
1686
+ uses_entity_info = annotations .uses_entity_info
1687
+ uses_envs = annotations .uses_envs
1688
+ else :
1689
+ uses_entity_info = annotations .uses_entity_info or None
1690
+ uses_envs = annotations .uses_envs or None
1691
+
1674
1692
result = PropertyDef (
1675
1693
expr = expr ,
1676
1694
prefix = AbstractNodeData .PREFIX_PROPERTY ,
@@ -1688,9 +1706,9 @@ def lower_property(self, full_decl: L.FullDecl) -> PropertyDef:
1688
1706
memoized = False ,
1689
1707
call_memoizable = False ,
1690
1708
memoize_in_populate = False ,
1691
- external = False ,
1692
- uses_entity_info = None ,
1693
- uses_envs = None ,
1709
+ external = annotations . external ,
1710
+ uses_entity_info = uses_entity_info ,
1711
+ uses_envs = uses_envs ,
1694
1712
optional_entity_info = False ,
1695
1713
warn_on_unused = True ,
1696
1714
ignore_warn_on_node = None ,
0 commit comments