@@ -384,17 +384,19 @@ def analyze_ref_expr(self, e: RefExpr, lvalue: bool = False) -> Type:
384384 if isinstance (result , PartialType ):
385385 result = self .chk .handle_partial_var_type (result , lvalue , node , e )
386386 elif isinstance (node , Decorator ):
387- result = self .analyze_var_ref (node .var , e )
387+ property_type = self .chk .get_property_instance (node )
388+ if property_type is not None :
389+ result = property_type
390+ else :
391+ result = self .analyze_var_ref (node .var , e )
388392 elif isinstance (node , OverloadedFuncDef ):
389393 result = node .type
390394 if result is None :
391395 if self .chk .in_checked_function () and node .items :
392396 self .chk .handle_cannot_determine_type (node .name , e )
393397 result = AnyType (TypeOfAny .from_error )
394- elif isinstance (node .items [0 ], Decorator ):
395- property_type = self .chk .get_property_instance (node .items [0 ])
396- if property_type is not None :
397- result = property_type
398+ elif property_type := self .chk .get_property_instance (node ):
399+ result = property_type
398400 elif isinstance (node , (FuncDef , TypeInfo , TypeAlias , MypyFile , TypeVarLikeExpr )):
399401 result = self .analyze_static_reference (node , e , e .is_alias_rvalue or lvalue )
400402 else :
@@ -435,11 +437,8 @@ def analyze_static_reference(
435437 special kinds (like TypeAlias, TypeInfo, etc.) on an instance or class object.
436438 # TODO: merge with analyze_ref_expr() when we are confident about performance.
437439 """
438- if isinstance (node , (Var , OverloadedFuncDef )):
440+ if isinstance (node , (Var , Decorator , OverloadedFuncDef )):
439441 return node .type or AnyType (TypeOfAny .special_form )
440- elif isinstance (node , Decorator ):
441- property_type = self .chk .get_property_instance (node )
442- return property_type or node .type or AnyType (TypeOfAny .special_form )
443442 elif isinstance (node , FuncDef ):
444443 return function_type (node , self .named_type ("builtins.function" ))
445444 elif isinstance (node , TypeInfo ):
0 commit comments