@@ -33,7 +33,7 @@ use crate::semantic_index::definition::{
33
33
use crate :: semantic_index:: expression:: { Expression , ExpressionKind } ;
34
34
use crate :: semantic_index:: place:: {
35
35
FileScopeId , NodeWithScopeKey , NodeWithScopeKind , NodeWithScopeRef , PlaceExpr ,
36
- PlaceTableBuilder , Scope , ScopeId , ScopeKind , ScopedPlaceId ,
36
+ PlaceExprSubSegment , PlaceTableBuilder , Scope , ScopeId , ScopeKind , ScopedPlaceId ,
37
37
} ;
38
38
use crate :: semantic_index:: predicate:: {
39
39
PatternPredicate , PatternPredicateKind , Predicate , PredicateNode , ScopedPredicateId ,
@@ -1964,12 +1964,14 @@ impl<'ast> Visitor<'ast> for SemanticIndexBuilder<'_, 'ast> {
1964
1964
| ast:: Expr :: Attribute ( ast:: ExprAttribute { ctx, .. } )
1965
1965
| ast:: Expr :: Subscript ( ast:: ExprSubscript { ctx, .. } ) => {
1966
1966
if let Ok ( mut place_expr) = PlaceExpr :: try_from ( expr) {
1967
- if self . is_method_of_class ( ) . is_some ( ) {
1967
+ if self . is_method_of_class ( ) . is_some ( )
1968
+ && matches ! ( place_expr. sub_segments( ) , & [ PlaceExprSubSegment :: Member ( _) ] )
1969
+ {
1968
1970
// We specifically mark attribute assignments to the first parameter of a method,
1969
1971
// i.e. typically `self` or `cls`.
1970
1972
let accessed_object_refers_to_first_parameter = self
1971
1973
. current_first_parameter_name
1972
- . is_some_and ( |fst| place_expr. root_name ( ) . as_str ( ) == fst) ;
1974
+ . is_some_and ( |fst| place_expr. root_name ( ) == fst) ;
1973
1975
1974
1976
if accessed_object_refers_to_first_parameter && place_expr. is_member ( ) {
1975
1977
place_expr. mark_instance_attribute ( ) ;
0 commit comments