mirror of https://github.com/astral-sh/ruff
check protocols nominally, too
This commit is contained in:
parent
3ff8a3c3db
commit
b55afcd48f
|
|
@ -133,14 +133,29 @@ impl<'db> Type<'db> {
|
||||||
disjointness_visitor: &IsDisjointVisitor<'db>,
|
disjointness_visitor: &IsDisjointVisitor<'db>,
|
||||||
) -> ConstraintSet<'db> {
|
) -> ConstraintSet<'db> {
|
||||||
let structurally_satisfied = if let Type::ProtocolInstance(self_protocol) = self {
|
let structurally_satisfied = if let Type::ProtocolInstance(self_protocol) = self {
|
||||||
self_protocol.interface(db).has_relation_to_impl(
|
let self_as_nominal = self_protocol.as_nominal_type();
|
||||||
db,
|
let other_as_nominal = protocol.as_nominal_type();
|
||||||
protocol.interface(db),
|
let nominal_match = match self_as_nominal.zip(other_as_nominal) {
|
||||||
inferable,
|
Some((self_as_nominal, other_as_nominal)) => self_as_nominal.has_relation_to_impl(
|
||||||
relation,
|
db,
|
||||||
relation_visitor,
|
other_as_nominal,
|
||||||
disjointness_visitor,
|
inferable,
|
||||||
)
|
relation,
|
||||||
|
relation_visitor,
|
||||||
|
disjointness_visitor,
|
||||||
|
),
|
||||||
|
_ => ConstraintSet::from(false),
|
||||||
|
};
|
||||||
|
nominal_match.or(db, || {
|
||||||
|
self_protocol.interface(db).has_relation_to_impl(
|
||||||
|
db,
|
||||||
|
protocol.interface(db),
|
||||||
|
inferable,
|
||||||
|
relation,
|
||||||
|
relation_visitor,
|
||||||
|
disjointness_visitor,
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
protocol
|
protocol
|
||||||
.inner
|
.inner
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue