@@ -968,7 +968,13 @@ def expand_and_bind_callable(
968968 # TODO: a decorated property can result in Overloaded here.
969969 assert isinstance (expanded , CallableType )
970970 if var .is_settable_property and mx .is_lvalue and var .setter_type is not None :
971- # TODO: use check_call() to infer better type, same as for __set__().
971+ if expanded .variables :
972+ type_ctx = mx .rvalue or TempNode (AnyType (TypeOfAny .special_form ), context = mx .context )
973+ _ , inferred_expanded = mx .chk .expr_checker .check_call (
974+ expanded , [type_ctx ], [ARG_POS ], mx .context
975+ )
976+ expanded = get_proper_type (inferred_expanded )
977+ assert isinstance (expanded , CallableType )
972978 if not expanded .arg_types :
973979 # This can happen when accessing invalid property from its own body,
974980 # error will be reported elsewhere.
@@ -1221,6 +1227,9 @@ def analyze_class_attribute_access(
12211227 is_classmethod = (is_decorated and cast (Decorator , node .node ).func .is_class ) or (
12221228 isinstance (node .node , SYMBOL_FUNCBASE_TYPES ) and node .node .is_class
12231229 )
1230+ is_staticmethod = (is_decorated and cast (Decorator , node .node ).func .is_static ) or (
1231+ isinstance (node .node , SYMBOL_FUNCBASE_TYPES ) and node .node .is_static
1232+ )
12241233 t = get_proper_type (t )
12251234 is_trivial_self = False
12261235 if isinstance (node .node , Decorator ):
@@ -1230,14 +1239,20 @@ def analyze_class_attribute_access(
12301239 is_trivial_self = node .node .is_trivial_self
12311240 if isinstance (t , FunctionLike ) and is_classmethod and not is_trivial_self :
12321241 t = check_self_arg (t , mx .self_type , False , mx .context , name , mx .msg )
1233- result = add_class_tvars (
1242+ t = add_class_tvars (
12341243 t ,
12351244 isuper ,
12361245 is_classmethod ,
12371246 mx ,
12381247 original_vars = original_vars ,
12391248 is_trivial_self = is_trivial_self ,
12401249 )
1250+ if is_decorated and not is_staticmethod :
1251+ t = expand_self_type_if_needed (
1252+ t , mx , cast (Decorator , node .node ).var , itype , is_class = is_classmethod
1253+ )
1254+
1255+ result = t
12411256 # __set__ is not called on class objects.
12421257 if not mx .is_lvalue :
12431258 result = analyze_descriptor_access (result , mx )
0 commit comments