Skip to content

Commit a0a0fd2

Browse files
committed
fix failing test
1 parent 775e2ba commit a0a0fd2

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

crates/ty_ide/src/completion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1849,7 +1849,7 @@ def test_point(p2: Point):
18491849
);
18501850

18511851
let completions = test.completions();
1852-
assert_eq!(completions, "orthogonal_direction");
1852+
test.assert_completions_include("orthogonal_direction");
18531853
}
18541854

18551855
impl CursorTest {

crates/ty_python_semantic/src/semantic_index/builder.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use crate::semantic_index::definition::{
3333
use crate::semantic_index::expression::{Expression, ExpressionKind};
3434
use crate::semantic_index::place::{
3535
FileScopeId, NodeWithScopeKey, NodeWithScopeKind, NodeWithScopeRef, PlaceExpr,
36-
PlaceTableBuilder, Scope, ScopeId, ScopeKind, ScopedPlaceId,
36+
PlaceExprSubSegment, PlaceTableBuilder, Scope, ScopeId, ScopeKind, ScopedPlaceId,
3737
};
3838
use crate::semantic_index::predicate::{
3939
PatternPredicate, PatternPredicateKind, Predicate, PredicateNode, ScopedPredicateId,
@@ -1964,12 +1964,14 @@ impl<'ast> Visitor<'ast> for SemanticIndexBuilder<'_, 'ast> {
19641964
| ast::Expr::Attribute(ast::ExprAttribute { ctx, .. })
19651965
| ast::Expr::Subscript(ast::ExprSubscript { ctx, .. }) => {
19661966
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+
{
19681970
// We specifically mark attribute assignments to the first parameter of a method,
19691971
// i.e. typically `self` or `cls`.
19701972
let accessed_object_refers_to_first_parameter = self
19711973
.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);
19731975

19741976
if accessed_object_refers_to_first_parameter && place_expr.is_member() {
19751977
place_expr.mark_instance_attribute();

crates/ty_python_semantic/src/types/ide_support.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ impl AllMembers {
186186
for function_scope_id in attribute_scopes(db, class_body_scope) {
187187
let place_table = index.place_table(function_scope_id);
188188
for instance_attribute in place_table.instance_attributes() {
189-
let name = instance_attribute.sub_segments()[0].as_member().unwrap();
189+
let name = instance_attribute.sub_segments()[0]
190+
.as_member()
191+
.expect("Non-members should never be registered as instance attributes");
190192
self.members.insert(name.clone());
191193
}
192194
}

0 commit comments

Comments
 (0)