@@ -823,6 +823,12 @@ def gen_variable_decl(self,
823
823
824
824
##### Expressions #####
825
825
826
+ def _get_class_attributes (self , class_decl , attr_name ):
827
+ class_decls = self .context .get_classes (self .namespace ).values ()
828
+ if attr_name == 'functions' :
829
+ return class_decl .get_callable_functions (class_decls )
830
+ return class_decl .get_all_fields (class_decls )
831
+
826
832
def generate_expr (self ,
827
833
expr_type : tp .Type = None ,
828
834
only_leaves = False ,
@@ -2354,9 +2360,7 @@ def _get_matching_objects(self,
2354
2360
self .function_type ):
2355
2361
continue
2356
2362
cls , type_map_var = self ._get_class (var_type )
2357
- # TODO for functions we should also consider
2358
- # get_callable_functions(class_decls.values())
2359
- for attr in getattr (cls , attr_name ): # function or field
2363
+ for attr in self ._get_class_attributes (cls , attr_name ):
2360
2364
attr_type = tp .substitute_type (
2361
2365
attr .get_type (), type_map_var )
2362
2366
if attr_type == self .bt_factory .get_void_type ():
@@ -2398,12 +2402,16 @@ def _get_matching_objects(self,
2398
2402
# parameter with type assignment map of the
2399
2403
# receiver class.
2400
2404
bound = tp .substitute_type (bound , type_map_var )
2401
- is_wildcard = bound .is_wildcard ()
2402
- if is_wildcard or func_type_var_map .get (
2405
+ if func_type_var_map .get (
2403
2406
t_param , bound ) != bound :
2404
2407
continue
2408
+ if bound .is_wildcard ():
2409
+ type_var_bounds = None
2410
+ break
2405
2411
if not bound .has_type_variables ():
2406
2412
type_var_bounds [t_param ] = bound
2413
+ if type_var_bounds is None :
2414
+ continue
2407
2415
type_var_bounds .update (type_map_var )
2408
2416
type_var_bounds .update (fun_type_var_map )
2409
2417
fun_type_var_map = tu .instantiate_parameterized_function (
@@ -2744,7 +2752,7 @@ def _get_matching_class_decls(self,
2744
2752
2745
2753
class_decls = []
2746
2754
for c in self .context .get_classes (self .namespace ).values ():
2747
- for attr in getattr (c , attr_name ): # field or function
2755
+ for attr in self . _get_class_attributes (c , attr_name ):
2748
2756
attr_type = attr .get_type ()
2749
2757
if not attr_type :
2750
2758
continue
0 commit comments