@@ -29,8 +29,8 @@ use crate::types::relation::{
2929use crate :: types:: {
3030 ApplyTypeMappingVisitor , BindingContext , BoundTypeVarInstance , CallableType , ErrorContext ,
3131 FindLegacyTypeVarsVisitor , KnownClass , MaterializationKind , ParamSpecAttrKind ,
32- ParameterDescription , SelfBinding , SubclassOfInner , TypeContext , TypeMapping , UnionBuilder ,
33- VarianceInferable , infer_complete_scope_types, todo_type,
32+ ParameterDescription , SelfBinding , TypeContext , TypeMapping , UnionBuilder , VarianceInferable ,
33+ infer_complete_scope_types, todo_type,
3434} ;
3535use crate :: { Db , FxOrderSet } ;
3636use ruff_python_ast:: { self as ast, name:: Name } ;
@@ -301,20 +301,6 @@ impl<'db> CallableSignature<'db> {
301301 }
302302 }
303303
304- /// Returns `true` if binding a concrete receiver could change which overloads remain
305- /// applicable.
306- ///
307- /// When every overload has the same receiver annotation (or they are all unannotated),
308- /// receiver-based pruning cannot affect the overload set, so we can skip the more expensive
309- /// relation checks during bound-method conversion.
310- pub ( crate ) fn has_receiver_sensitive_overloads ( & self ) -> bool {
311- let mut receiver_annotations = self . overloads . iter ( ) . map ( Signature :: receiver_annotation) ;
312- let Some ( first_annotation) = receiver_annotations. next ( ) else {
313- return false ;
314- } ;
315- receiver_annotations. any ( |annotation| annotation != first_annotation)
316- }
317-
318304 /// Replaces any occurrences of `typing.Self` in the parameter and return annotations with the
319305 /// given type. (Does not bind the `self` parameter; to do that, use
320306 /// [`bind_self`][Self::bind_self].)
@@ -745,13 +731,6 @@ impl<'db> Signature<'db> {
745731 }
746732 }
747733
748- fn receiver_annotation ( & self ) -> Option < Type < ' db > > {
749- let first_parameter = self . parameters . get ( 0 ) ?;
750- first_parameter
751- . is_positional ( )
752- . then ( || first_parameter. annotated_type ( ) )
753- }
754-
755734 /// Returns `true` if this signature's first parameter can accept the bound `self` type.
756735 ///
757736 /// This is used to prune impossible overloads when a method is bound to a concrete receiver.
@@ -765,35 +744,23 @@ impl<'db> Signature<'db> {
765744 return true ;
766745 }
767746
768- let annotated_self_ty = first_parameter. annotated_type ( ) ;
769- let expected_self_ty = if annotated_self_ty. contains_self ( db)
770- || annotated_self_ty. has_typevar_or_typevar_instance ( db)
771- {
772- annotated_self_ty
773- . bind_self_typevars ( db, self_type)
774- . apply_optional_specialization ( db, self_type. class_specialization ( db) )
775- } else {
776- annotated_self_ty
777- } ;
747+ let expected_self_ty = first_parameter
748+ . annotated_type ( )
749+ . bind_self_typevars ( db, self_type)
750+ . apply_optional_specialization ( db, self_type. class_specialization ( db) ) ;
778751
779752 if expected_self_ty. is_unknown ( ) {
780753 return true ;
781754 }
782755
783- if let Some ( can_bind) =
784- can_bind_self_to_concrete_receiver_fast_path ( db, self_type, expected_self_ty)
785- {
786- return can_bind;
787- }
788-
789756 let constraints = ConstraintSetBuilder :: new ( ) ;
790- let inferable_typevars = if expected_self_ty. has_typevar_or_typevar_instance ( db) {
791- self . inferable_typevars ( db)
792- } else {
793- InferableTypeVars :: None
794- } ;
795757 self_type
796- . when_assignable_to ( db, expected_self_ty, & constraints, inferable_typevars)
758+ . when_assignable_to (
759+ db,
760+ expected_self_ty,
761+ & constraints,
762+ self . inferable_typevars ( db) ,
763+ )
797764 . is_always_satisfied ( db)
798765 }
799766
@@ -921,58 +888,6 @@ impl<'db> Signature<'db> {
921888 }
922889}
923890
924- fn can_bind_self_to_concrete_receiver_fast_path < ' db > (
925- db : & ' db dyn Db ,
926- self_type : Type < ' db > ,
927- expected_self_ty : Type < ' db > ,
928- ) -> Option < bool > {
929- if self_type. has_dynamic ( db)
930- || self_type. has_typevar_or_typevar_instance ( db)
931- || expected_self_ty. has_dynamic ( db)
932- || expected_self_ty. has_typevar_or_typevar_instance ( db)
933- {
934- return None ;
935- }
936-
937- if let ( Some ( actual_class) , Some ( expected_class) ) = (
938- self_type. nominal_class ( db) ,
939- expected_self_ty. nominal_class ( db) ,
940- ) {
941- return Some ( actual_class. is_subclass_of ( db, expected_class) ) ;
942- }
943-
944- let actual_subclass = match self_type {
945- Type :: ClassLiteral ( _) | Type :: GenericAlias ( _) => {
946- match super :: SubclassOfType :: try_from_type ( db, self_type) {
947- Some ( Type :: SubclassOf ( subclass_of) ) => Some ( subclass_of) ,
948- _ => None ,
949- }
950- }
951- Type :: SubclassOf ( subclass_of) => Some ( subclass_of) ,
952- _ => None ,
953- } ?;
954- let expected_subclass = match expected_self_ty {
955- Type :: ClassLiteral ( _) | Type :: GenericAlias ( _) => {
956- match super :: SubclassOfType :: try_from_type ( db, expected_self_ty) {
957- Some ( Type :: SubclassOf ( subclass_of) ) => Some ( subclass_of) ,
958- _ => None ,
959- }
960- }
961- Type :: SubclassOf ( subclass_of) => Some ( subclass_of) ,
962- _ => None ,
963- } ?;
964-
965- match (
966- actual_subclass. subclass_of ( ) ,
967- expected_subclass. subclass_of ( ) ,
968- ) {
969- ( SubclassOfInner :: Class ( actual_class) , SubclassOfInner :: Class ( expected_class) ) => {
970- Some ( actual_class. is_subclass_of ( db, expected_class) )
971- }
972- _ => None ,
973- }
974- }
975-
976891impl < ' db > VarianceInferable < ' db > for & Signature < ' db > {
977892 fn variance_of ( self , db : & ' db dyn Db , typevar : BoundTypeVarInstance < ' db > ) -> TypeVarVariance {
978893 tracing:: trace!(
0 commit comments