Skip to content

Commit 0c7ca15

Browse files
committed
[ty] Remove Self from generic context when binding Self
1 parent 7fd5d53 commit 0c7ca15

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

crates/ty_python_semantic/src/types.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6777,8 +6777,15 @@ impl<'db> TypeMapping<'_, 'db> {
67776777
| TypeMapping::PromoteLiterals
67786778
| TypeMapping::BindLegacyTypevars(_)
67796779
| TypeMapping::MarkTypeVarsInferable(_)
6780-
| TypeMapping::Materialize(_)
6781-
| TypeMapping::BindSelf(_) => context,
6780+
| TypeMapping::Materialize(_) => context,
6781+
TypeMapping::BindSelf(_) => GenericContext::from_typevar_instances(
6782+
db,
6783+
context
6784+
.variables(db)
6785+
.iter()
6786+
.filter(|var| !var.typevar(db).is_self(db))
6787+
.copied(),
6788+
),
67826789
TypeMapping::ReplaceSelf { new_upper_bound } => GenericContext::from_typevar_instances(
67836790
db,
67846791
context.variables(db).iter().map(|typevar| {

0 commit comments

Comments
 (0)