nac3artiq: update InnerResolver's "pyid_to_type" table if class contain constructor function #309

Merged
sb10q merged 7 commits from issue-139-2 into master 2022-07-28 19:18:36 +08:00
1 changed files with 11 additions and 10 deletions
Showing only changes of commit 3585ab9d06 - Show all commits

View File

@ -551,17 +551,18 @@ impl InnerResolver {
let constructor_ty = pyid_to_def let constructor_ty = pyid_to_def
.get(&py_obj_id) .get(&py_obj_id)
.and_then(|def_id| { .and_then(|def_id| {
defs.iter() defs
.find_map(|def| { .iter()
if let TopLevelDef::Class { .find_map(|def| {
object_id, methods, constructor, .. if let TopLevelDef::Class {
} = &*def.read() { object_id, methods, constructor, ..
if object_id == def_id && constructor.is_some() && methods.iter().any(|(s, _, _)| s == &"__init__".into()) { } = &*def.read() {
return constructor.clone(); if object_id == def_id && constructor.is_some() && methods.iter().any(|(s, _, _)| s == &"__init__".into()) {
} return constructor.clone();
} }
None }
}) None
})
}); });
if let Some(ty) = constructor_ty { if let Some(ty) = constructor_ty {