Skip to content

Commit 9a37861

Browse files
committed
skip current type when specializing
1 parent f82b3f1 commit 9a37861

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

crates/ty_python_semantic/src/types/generics.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ impl<'db> GenericContext<'db> {
556556
let partial = PartialSpecialization {
557557
generic_context: self,
558558
types: &types,
559+
skip: Some(i),
559560
};
560561
let updated = types[i].apply_type_mapping(
561562
db,
@@ -626,6 +627,7 @@ impl<'db> GenericContext<'db> {
626627
let partial = PartialSpecialization {
627628
generic_context: self,
628629
types: &expanded[0..idx],
630+
skip: None,
629631
};
630632
let default = default.apply_type_mapping(
631633
db,
@@ -1360,6 +1362,7 @@ impl<'db> Specialization<'db> {
13601362
pub struct PartialSpecialization<'a, 'db> {
13611363
generic_context: GenericContext<'db>,
13621364
types: &'a [Type<'db>],
1365+
skip: Option<usize>,
13631366
}
13641367

13651368
impl<'db> PartialSpecialization<'_, 'db> {
@@ -1374,6 +1377,9 @@ impl<'db> PartialSpecialization<'_, 'db> {
13741377
.generic_context
13751378
.variables_inner(db)
13761379
.get_index_of(&bound_typevar.identity(db))?;
1380+
if self.skip.is_some_and(|skip| skip == index) {
1381+
return Some(Type::unknown());
1382+
}
13771383
self.types.get(index).copied()
13781384
}
13791385
}

0 commit comments

Comments
 (0)