File tree Expand file tree Collapse file tree 2 files changed +49
-15
lines changed
crates/ty_python_semantic/src/types Expand file tree Collapse file tree 2 files changed +49
-15
lines changed Original file line number Diff line number Diff line change @@ -1661,22 +1661,38 @@ impl<'db> SpecializationBuilder<'db> {
16611661 }
16621662
16631663 ( Type :: Callable ( formal_callable) , _) => {
1664- if let Some ( actual_callable) = actual
1664+ let Some ( actual_callable) = actual
16651665 . try_upcast_to_callable ( self . db )
16661666 . and_then ( CallableTypes :: exactly_one)
1667- {
1668- for formal_signature in & formal_callable. signatures ( self . db ) . overloads {
1669- for actual_signature in & actual_callable. signatures ( self . db ) . overloads {
1670- if let Some ( formal_return_ty) = formal_signature. return_ty
1671- && let Some ( actual_return_ty) = actual_signature. return_ty
1672- {
1673- self . infer_map_impl (
1674- formal_return_ty,
1675- actual_return_ty,
1676- polarity,
1677- & mut f,
1678- ) ?;
1679- }
1667+ else {
1668+ return Ok ( ( ) ) ;
1669+ } ;
1670+
1671+ let [ formal_signature] = formal_callable. signatures ( self . db ) . overloads . as_slice ( )
1672+ else {
1673+ return Ok ( ( ) ) ;
1674+ } ;
1675+ let [ actual_signature] = actual_callable. signatures ( self . db ) . overloads . as_slice ( )
1676+ else {
1677+ return Ok ( ( ) ) ;
1678+ } ;
1679+
1680+ let when = formal_signature. when_constraint_set_assignable_to (
1681+ self . db ,
1682+ actual_signature,
1683+ self . inferable ,
1684+ ) ;
1685+ for formal_signature in & formal_callable. signatures ( self . db ) . overloads {
1686+ for actual_signature in & actual_callable. signatures ( self . db ) . overloads {
1687+ if let Some ( formal_return_ty) = formal_signature. return_ty
1688+ && let Some ( actual_return_ty) = actual_signature. return_ty
1689+ {
1690+ self . infer_map_impl (
1691+ formal_return_ty,
1692+ actual_return_ty,
1693+ polarity,
1694+ & mut f,
1695+ ) ?;
16801696 }
16811697 }
16821698 }
Original file line number Diff line number Diff line change @@ -793,6 +793,22 @@ impl<'db> Signature<'db> {
793793 result
794794 }
795795
796+ pub ( crate ) fn when_constraint_set_assignable_to (
797+ & self ,
798+ db : & ' db dyn Db ,
799+ other : & Signature < ' db > ,
800+ inferable : InferableTypeVars < ' _ , ' db > ,
801+ ) -> ConstraintSet < ' db > {
802+ self . has_relation_to_impl (
803+ db,
804+ other,
805+ inferable,
806+ TypeRelation :: ConstraintSetAssignability ,
807+ & HasRelationToVisitor :: default ( ) ,
808+ & IsDisjointVisitor :: default ( ) ,
809+ )
810+ }
811+
796812 /// Implementation of subtyping and assignability for signature.
797813 fn has_relation_to_impl (
798814 & self ,
@@ -1129,7 +1145,9 @@ impl<'db> Signature<'db> {
11291145 break ;
11301146 }
11311147
1132- _ => return ConstraintSet :: from ( false ) ,
1148+ _ => {
1149+ return ConstraintSet :: from ( false ) ;
1150+ }
11331151 }
11341152 }
11351153 }
You can’t perform that action at this time.
0 commit comments