(
self, expr: CallExpr, callee: RefExpr, arg_values: list[Value]
)
| 1237 | return isinstance(expr.expr, RefExpr) and isinstance(expr.expr.node, MypyFile) |
| 1238 | |
| 1239 | def call_refexpr_with_args( |
| 1240 | self, expr: CallExpr, callee: RefExpr, arg_values: list[Value] |
| 1241 | ) -> Value: |
| 1242 | # Handle data-driven special-cased primitive call ops. |
| 1243 | if callee.fullname and expr.arg_kinds == [ARG_POS] * len(arg_values): |
| 1244 | fullname = get_call_target_fullname(callee) |
| 1245 | primitive_candidates = function_ops.get(fullname, []) |
| 1246 | target = self.builder.matching_primitive_op( |
| 1247 | primitive_candidates, arg_values, expr.line, self.node_type(expr) |
| 1248 | ) |
| 1249 | if target: |
| 1250 | return target |
| 1251 | |
| 1252 | # Standard native call if signature and fullname are good and all arguments are positional |
| 1253 | # or named. |
| 1254 | callee_node = callee.node |
| 1255 | if isinstance(callee_node, OverloadedFuncDef): |
| 1256 | callee_node = callee_node.impl |
| 1257 | # TODO: use native calls for any decorated functions which have all their decorators |
| 1258 | # removed, not just singledispatch functions (which we don't do now just in case those |
| 1259 | # decorated functions are callable classes or cannot be called without the python API for |
| 1260 | # some other reason) |
| 1261 | if ( |
| 1262 | isinstance(callee_node, Decorator) |
| 1263 | and callee_node.func not in self.fdefs_to_decorators |
| 1264 | and callee_node.func in self.singledispatch_impls |
| 1265 | ): |
| 1266 | callee_node = callee_node.func |
| 1267 | if ( |
| 1268 | callee_node is not None |
| 1269 | and callee.fullname |
| 1270 | and callee_node in self.mapper.func_to_decl |
| 1271 | and all(kind in (ARG_POS, ARG_NAMED) for kind in expr.arg_kinds) |
| 1272 | ): |
| 1273 | decl = self.mapper.func_to_decl[callee_node] |
| 1274 | return self.builder.call(decl, arg_values, expr.arg_kinds, expr.arg_names, expr.line) |
| 1275 | |
| 1276 | # Fall back to a Python call |
| 1277 | function = self.accept(callee) |
| 1278 | return self.py_call( |
| 1279 | function, arg_values, expr.line, arg_kinds=expr.arg_kinds, arg_names=expr.arg_names |
| 1280 | ) |
| 1281 | |
| 1282 | def shortcircuit_expr(self, expr: OpExpr) -> Value: |
| 1283 | def handle_right() -> Value: |
no test coverage detected