Skip to content

Commit f30b7f9

Browse files
committed
Explicitly disable use site variance when needed
1 parent 3d51987 commit f30b7f9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/generators/generator.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,8 @@ def _get_classes_with_assignable_fields(self):
10041004
t, self.get_types(exclude_arrays=True),
10051005
variance_choices=variance_choices,
10061006
disable_variance_functions=self.disable_variance_functions,
1007-
enable_pecs=self.enable_pecs)
1007+
enable_pecs=self.enable_pecs
1008+
)
10081009
# Ok here we create a new field whose type corresponds
10091010
# to the type argument with which the class 'c' is
10101011
# instantiated.
@@ -2611,7 +2612,8 @@ def _get_matching_class(self,
26112612
only_regular=True, type_var_map=type_var_map,
26122613
enable_pecs=self.enable_pecs,
26132614
disable_variance_functions=self.disable_variance_functions,
2614-
variance_choices=variance_choices
2615+
variance_choices=variance_choices,
2616+
disable_variance=variance_choices is None
26152617
)
26162618
msg = ("Found parameterized class {} with TypeVarMap {} and "
26172619
"incomplete TypeVarMap {}")
@@ -2642,7 +2644,8 @@ def _get_matching_class(self,
26422644
cls.get_type(), self.get_types(),
26432645
only_regular=True, type_var_map=cls_type_var_map,
26442646
enable_pecs=self.enable_pecs,
2645-
variance_choices=variance_choices
2647+
variance_choices=variance_choices,
2648+
disable_variance=variance_choices is None
26462649
)
26472650
else:
26482651
if is_parameterized_func:
@@ -2836,7 +2839,8 @@ def _gen_matching_class(self,
28362839
type_var_map=type_map,
28372840
enable_pecs=self.enable_pecs,
28382841
disable_variance_functions=self.disable_variance_functions,
2839-
variance_choices=variance_choices
2842+
variance_choices=variance_choices,
2843+
disable_variance=variance_choices is None
28402844
)
28412845
else:
28422846
cls_type, params_map = cls.get_type(), {}
@@ -2854,8 +2858,10 @@ def _gen_matching_class(self,
28542858
attr.type_parameters, self.get_types(), only_regular=True,
28552859
type_var_map=params_map)
28562860

2857-
msg = "Generated a class {} with an attribute {} of type {}"
2858-
log(self.logger, msg.format(cls.name, attr_name, etype))
2861+
msg = ("Generated a class {} with an attribute {} of type {}; "
2862+
"ClassTypeVarMap {}, FuncTypeVarMap {}")
2863+
log(self.logger, msg.format(cls.name, attr_name, etype,
2864+
params_map, func_type_var_map))
28592865
return gu.AttrAccessInfo(cls_type, params_map, attr,
28602866
func_type_var_map)
28612867
return None

0 commit comments

Comments
 (0)