MCPcopy Index your code
hub / github.com/python/mypy / MethodCall

Class MethodCall

mypyc/ir/ops.py:660–688  ·  view source on GitHub ↗

Native method call obj.method(arg, ...)

Source from the content-addressed store, hash-verified

658
659@final
660class MethodCall(RegisterOp):
661 """Native method call obj.method(arg, ...)"""
662
663 def __init__(self, obj: Value, method: str, args: list[Value], line: int = -1) -> None:
664 self.obj = obj
665 self.method = method
666 self.args = args
667 assert isinstance(obj.type, RInstance), "Methods can only be called on instances"
668 self.receiver_type = obj.type
669 method_ir = self.receiver_type.class_ir.method_sig(method)
670 assert method_ir is not None, "{} doesn't have method {}".format(
671 self.receiver_type.name, method
672 )
673 ret_type = method_ir.ret_type
674 self.type = ret_type
675 if not ret_type.error_overlap:
676 self.error_kind = ERR_MAGIC
677 else:
678 self.error_kind = ERR_MAGIC_OVERLAPPING
679 super().__init__(line)
680
681 def sources(self) -> list[Value]:
682 return self.args.copy() + [self.obj]
683
684 def set_sources(self, new: list[Value]) -> None:
685 *self.args, self.obj = new
686
687 def accept(self, visitor: OpVisitor[T]) -> T:
688 return visitor.visit_method_call(self)
689
690
691@final

Callers 7

gen_conditionMethod · 0.90
assignMethod · 0.90
gen_glue_ne_methodFunction · 0.90
transform_withFunction · 0.90
emit_yield_from_or_awaitFunction · 0.90
gen_method_callMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…