diff options
Diffstat (limited to 'Lib/symtable.py')
-rw-r--r-- | Lib/symtable.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/symtable.py b/Lib/symtable.py index 500a990..73e9fb3 100644 --- a/Lib/symtable.py +++ b/Lib/symtable.py @@ -228,8 +228,25 @@ class Class(SymbolTable): """ if self.__methods is None: d = {} + + def is_local_symbol(ident): + flags = self._table.symbols.get(ident, 0) + return ((flags >> SCOPE_OFF) & SCOPE_MASK) == LOCAL + for st in self._table.children: - d[st.name] = 1 + # pick the function-like symbols that are local identifiers + if is_local_symbol(st.name): + match st.type: + case _symtable.TYPE_FUNCTION: + d[st.name] = 1 + case _symtable.TYPE_TYPE_PARAMETERS: + # Get the function-def block in the annotation + # scope 'st' with the same identifier, if any. + scope_name = st.name + for c in st.children: + if c.name == scope_name and c.type == _symtable.TYPE_FUNCTION: + d[st.name] = 1 + break self.__methods = tuple(d) return self.__methods |