diff --git a/crates/ty_python_semantic/src/types/constraints.rs b/crates/ty_python_semantic/src/types/constraints.rs index a019860563..2cd245dc9a 100644 --- a/crates/ty_python_semantic/src/types/constraints.rs +++ b/crates/ty_python_semantic/src/types/constraints.rs @@ -439,6 +439,10 @@ impl<'db> ConstraintSet<'db> { pub(crate) fn display(self, db: &'db dyn Db) -> impl Display { self.node.simplify_for_display(db).display(db) } + + pub(crate) fn display_graph(self, db: &'db dyn Db, prefix: &dyn Display) -> impl Display { + self.node.display_graph(db, prefix) + } } impl From for ConstraintSet<'_> { diff --git a/crates/ty_python_semantic/src/types/generics.rs b/crates/ty_python_semantic/src/types/generics.rs index f662456724..f4eaf85fa3 100644 --- a/crates/ty_python_semantic/src/types/generics.rs +++ b/crates/ty_python_semantic/src/types/generics.rs @@ -1651,7 +1651,10 @@ impl<'db> SpecializationBuilder<'db> { } (Type::Callable(formal_callable), _) => { + eprintln!("==> {}", formal.display(self.db)); + eprintln!(" {}", actual.display(self.db)); let Some(actual_callables) = actual.try_upcast_to_callable(self.db) else { + eprintln!(" -> NOPE"); return Ok(()); }; @@ -1659,19 +1662,31 @@ impl<'db> SpecializationBuilder<'db> { for formal_signature in &formal_callable.signatures(self.db).overloads { for actual_callable in actual_callables.as_slice() { for actual_signature in &actual_callable.signatures(self.db).overloads { - when.union( + eprintln!(" -> pair"); + eprintln!(" {}", formal_signature.display(self.db)); + eprintln!(" {}", actual_signature.display(self.db)); + let x = formal_signature.when_constraint_set_assignable_to( self.db, - formal_signature.when_constraint_set_assignable_to( - self.db, - actual_signature, - self.inferable, - ), + actual_signature, + self.inferable, ); + eprintln!(" {}", x.display(self.db)); + eprintln!(" {}", x.display_graph(self.db, &" ")); + when.union(self.db, x); } } } + eprintln!("--> combined"); + eprintln!(" {}", when.display(self.db)); + eprintln!(" {}", when.display_graph(self.db, &" ")); when.for_each_path(self.db, |path| { + eprintln!( + "--> path [{}]", + path.positive_constraints() + .map(|c| c.display(self.db)) + .format(", ") + ); for constraint in path.positive_constraints() { let typevar = constraint.typevar(self.db); let lower = constraint.lower(self.db); diff --git a/crates/ty_python_semantic/src/types/signatures.rs b/crates/ty_python_semantic/src/types/signatures.rs index ac7501c765..3380f21eb7 100644 --- a/crates/ty_python_semantic/src/types/signatures.rs +++ b/crates/ty_python_semantic/src/types/signatures.rs @@ -975,19 +975,33 @@ impl<'db> Signature<'db> { let mut check_types = |type1: Option>, type2: Option>| { let type1 = type1.unwrap_or(Type::unknown()); let type2 = type2.unwrap_or(Type::unknown()); - !result - .intersect( - db, - type1.has_relation_to_impl( + eprintln!(" ~> {} ≤ {}", type1.display(db), type2.display(db)); + eprintln!( + " ~> when {}", + type1 + .has_relation_to_impl( db, type2, inferable, relation, relation_visitor, disjointness_visitor, - ), - ) - .is_never_satisfied(db) + ) + .display(db) + ); + result.intersect( + db, + type1.has_relation_to_impl( + db, + type2, + inferable, + relation, + relation_visitor, + disjointness_visitor, + ), + ); + eprintln!(" ~> inter {}", result.display(db)); + !result.is_never_satisfied(db) }; // Return types are covariant.