Skip to content

Commit 2a6dde4

Browse files
authored
[ty] Remove Self from generic context when binding Self (#20364)
## Summary This mainly removes an internal inconsistency, where we didn't remove the `Self` type variable when eagerly binding `Self` to an instance type. It has no observable effect, apparently. builds on top of #20328 ## Test Plan None
1 parent 25cbf38 commit 2a6dde4

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)