Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mypyc/irbuild/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Callable, Sequence

from mypy.nodes import (
ARG_NAMED,
ARG_POS,
LDEF,
AssertTypeExpr,
Expand Down Expand Up @@ -355,6 +356,7 @@ def translate_method_call(builder: IRBuilder, expr: CallExpr, callee: MemberExpr
and isinstance(callee.expr.node, TypeInfo)
and callee.expr.node in builder.mapper.type_to_ir
and builder.mapper.type_to_ir[callee.expr.node].has_method(callee.name)
and all(kind in (ARG_POS, ARG_NAMED) for kind in expr.arg_kinds)
):
# Call a method via the *class*
assert isinstance(callee.expr.node, TypeInfo)
Expand Down
24 changes: 24 additions & 0 deletions mypyc/test-data/run-classes.test
Original file line number Diff line number Diff line change
Expand Up @@ -2631,3 +2631,27 @@ print(f'{Player.MIN = }')
from native import Player
[out]
Player.MIN = <Player.MIN: 1>

[case testStaticCallsWithUnpackingArgs]
from typing import Tuple

class Foo:
@staticmethod
def static(a: int, b: int, c: int) -> Tuple[int, int, int]:
return (c+1, a+2, b+3)

@classmethod
def clsmethod(cls, a: int, b: int, c: int) -> Tuple[int, int, int]:
return (c+1, a+2, b+3)


print(Foo.static(*[10, 20, 30]))
print(Foo.static(*(40, 50), *[60]))
assert Foo.static(70, 80, *[90]) == Foo.clsmethod(70, *(80, 90))

[file driver.py]
import native

[out]
(31, 12, 23)
(61, 42, 53)