mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-07 21:25:08 +00:00
fix recursive protocols
This commit is contained in:
parent
66932b5087
commit
c548b0d085
2 changed files with 14 additions and 7 deletions
|
@ -1773,7 +1773,8 @@ class RecursiveOptionalParent(Protocol):
|
|||
|
||||
static_assert(is_assignable_to(RecursiveOptionalParent, RecursiveOptionalParent))
|
||||
|
||||
static_assert(is_assignable_to(RecursiveNonFullyStatic, RecursiveOptionalParent))
|
||||
# Due to invariance of mutable attribute members, neither is assignable to the other
|
||||
static_assert(not is_assignable_to(RecursiveNonFullyStatic, RecursiveOptionalParent))
|
||||
static_assert(not is_assignable_to(RecursiveOptionalParent, RecursiveNonFullyStatic))
|
||||
|
||||
class Other(Protocol):
|
||||
|
|
|
@ -152,13 +152,19 @@ impl<'db> ProtocolInterface<'db> {
|
|||
other: Self,
|
||||
relation: TypeRelation,
|
||||
) -> bool {
|
||||
let this_interface = self.inner(db);
|
||||
let this_interface = self
|
||||
.normalized_impl(db, &mut TypeVisitor::default())
|
||||
.inner(db);
|
||||
|
||||
other.inner(db).iter().all(|(name, super_data)| {
|
||||
this_interface
|
||||
.get(name)
|
||||
.is_some_and(|sub_data| sub_data.has_relation_to(db, super_data, relation))
|
||||
})
|
||||
other
|
||||
.normalized_impl(db, &mut TypeVisitor::default())
|
||||
.inner(db)
|
||||
.iter()
|
||||
.all(|(name, super_data)| {
|
||||
this_interface
|
||||
.get(name)
|
||||
.is_some_and(|sub_data| sub_data.has_relation_to(db, super_data, relation))
|
||||
})
|
||||
}
|
||||
|
||||
/// Return `true` if the types of any of the members match the closure passed in.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue