[red-knot] fix ordering of ClassDef semantic index building (#16915)
## Summary From #16861 This PR fixes the incorrect `ClassDef` handling of `SemanticIndexBuilder::visit_stmt`, which fixes some of the incorrect behavior of referencing the class itself in the class scope (a complete fix requires a different fix, which will be done in the another PR). --------- Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
committed by
GitHub
parent
bb07ccd783
commit
ee51c2a389
@@ -926,9 +926,6 @@ where
|
||||
self.visit_decorator(decorator);
|
||||
}
|
||||
|
||||
let symbol = self.add_symbol(class.name.id.clone());
|
||||
self.add_definition(symbol, class);
|
||||
|
||||
self.with_type_params(
|
||||
NodeWithScopeRef::ClassTypeParameters(class),
|
||||
class.type_params.as_deref(),
|
||||
@@ -943,6 +940,10 @@ where
|
||||
builder.pop_scope()
|
||||
},
|
||||
);
|
||||
|
||||
// In Python runtime semantics, a class is registered after its scope is evaluated.
|
||||
let symbol = self.add_symbol(class.name.id.clone());
|
||||
self.add_definition(symbol, class);
|
||||
}
|
||||
ast::Stmt::TypeAlias(type_alias) => {
|
||||
let symbol = self.add_symbol(
|
||||
|
||||
Reference in New Issue
Block a user