fix: codegen bug in CPython 3.7~3.10

This commit is contained in:
Shunsuke Shibayama 2024-10-10 13:34:19 +09:00
parent 83c57edf0e
commit b7647c7f80
2 changed files with 5 additions and 1 deletions

View file

@ -2799,7 +2799,9 @@ impl PyCodeGenerator {
return self.emit_call_fake_method(obj, func_name, method_name, args);
}
let is_type = method_name.ref_t().is_poly_meta_type();
let kind = if self.py_version.minor >= Some(11) || method_name.vi.t.is_method() {
let kind = if self.py_version.minor >= Some(11)
|| (method_name.vi.t.is_method() && args.kw_args.is_empty())
{
BoundAttr
} else {
UnboundAttr

View file

@ -14,12 +14,14 @@ D.
new y = Self { .y; }
@staticmethod
foo x = x + 1
bar self, x := 1 = self.y + x
one = Self.new 1
D|<: Eq|.
`==` self, other = self.y == other.y
d = D.new 1
assert d.foo(1) == 2
assert d.bar(x:=2) == 3
c = C.new { .x = D.new(1) }
assert c.x.y == 1