@@ -1235,13 +1235,10 @@ def gen_method_call(
12351235
12361236 # If the base type is one of ours, do a MethodCall
12371237 fast_name = FAST_PREFIX + name
1238- if (
1239- isinstance (base .type , RInstance )
1240- and (base .type .class_ir .is_ext_class or base .type .class_ir .has_method (fast_name ))
1241- and not base .type .class_ir .builtin_base
1242- ):
1238+ if isinstance (base .type , RInstance ):
12431239 name = name if base .type .class_ir .is_ext_class else fast_name
1244- if base .type .class_ir .has_method (name ):
1240+
1241+ def build_args () -> list [Value ]:
12451242 decl = base .type .class_ir .method_decl (name )
12461243 if arg_kinds is None :
12471244 assert arg_names is None , "arg_kinds not present but arg_names is"
@@ -1252,15 +1249,28 @@ def gen_method_call(
12521249
12531250 # Normalize args to positionals.
12541251 assert decl .bound_sig
1255- arg_values = self .native_args_to_positional (
1252+ return self .native_args_to_positional (
12561253 arg_values , arg_kinds , arg_names , decl .bound_sig , line
12571254 )
1258- return self .add (MethodCall (base , name , arg_values , line ))
1259- elif base .type .class_ir .has_attr (name ):
1260- function = self .add (GetAttr (base , name , line ))
1261- return self .py_call (
1262- function , arg_values , line , arg_kinds = arg_kinds , arg_names = arg_names
1263- )
1255+
1256+ if (
1257+ (base .type .class_ir .is_ext_class or base .type .class_ir .has_method (fast_name ))
1258+ and not base .type .class_ir .builtin_base
1259+ ):
1260+ if base .type .class_ir .has_method (name ):
1261+ arg_values = build_args ()
1262+ return self .add (MethodCall (base , name , arg_values , line ))
1263+ elif base .type .class_ir .has_attr (name ):
1264+ function = self .add (GetAttr (base , name , line ))
1265+ return self .py_call (
1266+ function , arg_values , line , arg_kinds = arg_kinds , arg_names = arg_names
1267+ )
1268+ elif base .type .class_ir .has_method (name ) and base .type .class_ir .is_method_final (name ):
1269+ # does this really work tho? must check more. why wasnt this done before? what do all the if checks do above?
1270+ decl = base .type .class_ir .method_decl (name )
1271+ # should this be a MethodCall?
1272+ arg_values = build_args ()
1273+ return self .call (decl , arg_values , [ARG_POS ] * len (arg_values ), [None ], line )
12641274
12651275 elif isinstance (base .type , RUnion ):
12661276 return self .union_method_call (
0 commit comments