@@ -32,7 +32,7 @@ use crate::types::tuple::{TupleLength, TupleType};
3232use crate :: types:: {
3333 BoundMethodType , ClassLiteral , DataclassParams , FieldInstance , KnownBoundMethodType ,
3434 KnownClass , KnownInstanceType , MemberLookupPolicy , PropertyInstanceType , SpecialFormType ,
35- TrackedConstraintSet , TypeAliasType , TypeContext , TypeMapping , UnionBuilder , UnionType ,
35+ TrackedConstraintSet , TypeAliasType , TypeContext , UnionBuilder , UnionType ,
3636 WrapperDescriptorKind , enums, ide_support, todo_type,
3737} ;
3838use ruff_db:: diagnostic:: { Annotation , Diagnostic , SubDiagnostic , SubDiagnosticSeverity } ;
@@ -1701,10 +1701,6 @@ impl<'db> CallableBinding<'db> {
17011701 parameter_type =
17021702 parameter_type. apply_specialization ( db, specialization) ;
17031703 }
1704- if let Some ( inherited_specialization) = overload. inherited_specialization {
1705- parameter_type =
1706- parameter_type. apply_specialization ( db, inherited_specialization) ;
1707- }
17081704 union_parameter_types[ parameter_index. saturating_sub ( skipped_parameters) ]
17091705 . add_in_place ( parameter_type) ;
17101706 }
@@ -1983,7 +1979,7 @@ impl<'db> CallableBinding<'db> {
19831979 for overload in overloads. iter ( ) . take ( MAXIMUM_OVERLOADS ) {
19841980 diag. info ( format_args ! (
19851981 " {}" ,
1986- overload. signature( context. db( ) , None ) . display( context. db( ) )
1982+ overload. signature( context. db( ) ) . display( context. db( ) )
19871983 ) ) ;
19881984 }
19891985 if overloads. len ( ) > MAXIMUM_OVERLOADS {
@@ -2444,7 +2440,6 @@ struct ArgumentTypeChecker<'a, 'db> {
24442440 errors : & ' a mut Vec < BindingError < ' db > > ,
24452441
24462442 specialization : Option < Specialization < ' db > > ,
2447- inherited_specialization : Option < Specialization < ' db > > ,
24482443}
24492444
24502445impl < ' a , ' db > ArgumentTypeChecker < ' a , ' db > {
@@ -2466,7 +2461,6 @@ impl<'a, 'db> ArgumentTypeChecker<'a, 'db> {
24662461 call_expression_tcx,
24672462 errors,
24682463 specialization : None ,
2469- inherited_specialization : None ,
24702464 }
24712465 }
24722466
@@ -2498,9 +2492,7 @@ impl<'a, 'db> ArgumentTypeChecker<'a, 'db> {
24982492 }
24992493
25002494 fn infer_specialization ( & mut self ) {
2501- if self . signature . generic_context . is_none ( )
2502- && self . signature . inherited_generic_context . is_none ( )
2503- {
2495+ if self . signature . generic_context . is_none ( ) {
25042496 return ;
25052497 }
25062498
@@ -2542,14 +2534,6 @@ impl<'a, 'db> ArgumentTypeChecker<'a, 'db> {
25422534 }
25432535
25442536 self . specialization = self . signature . generic_context . map ( |gc| builder. build ( gc) ) ;
2545- self . inherited_specialization = self . signature . inherited_generic_context . map ( |gc| {
2546- // The inherited generic context is used when inferring the specialization of a generic
2547- // class from a constructor call. In this case (only), we promote any typevars that are
2548- // inferred as a literal to the corresponding instance type.
2549- builder
2550- . build ( gc)
2551- . apply_type_mapping ( self . db , & TypeMapping :: PromoteLiterals )
2552- } ) ;
25532537 }
25542538
25552539 fn check_argument_type (
@@ -2566,11 +2550,6 @@ impl<'a, 'db> ArgumentTypeChecker<'a, 'db> {
25662550 argument_type = argument_type. apply_specialization ( self . db , specialization) ;
25672551 expected_ty = expected_ty. apply_specialization ( self . db , specialization) ;
25682552 }
2569- if let Some ( inherited_specialization) = self . inherited_specialization {
2570- argument_type =
2571- argument_type. apply_specialization ( self . db , inherited_specialization) ;
2572- expected_ty = expected_ty. apply_specialization ( self . db , inherited_specialization) ;
2573- }
25742553 // This is one of the few places where we want to check if there's _any_ specialization
25752554 // where assignability holds; normally we want to check that assignability holds for
25762555 // _all_ specializations.
@@ -2742,8 +2721,8 @@ impl<'a, 'db> ArgumentTypeChecker<'a, 'db> {
27422721 }
27432722 }
27442723
2745- fn finish ( self ) -> ( Option < Specialization < ' db > > , Option < Specialization < ' db > > ) {
2746- ( self . specialization , self . inherited_specialization )
2724+ fn finish ( self ) -> Option < Specialization < ' db > > {
2725+ self . specialization
27472726 }
27482727}
27492728
@@ -2807,10 +2786,6 @@ pub(crate) struct Binding<'db> {
28072786 /// The specialization that was inferred from the argument types, if the callable is generic.
28082787 specialization : Option < Specialization < ' db > > ,
28092788
2810- /// The specialization that was inferred for a class method's containing generic class, if it
2811- /// is being used to infer a specialization for the class.
2812- inherited_specialization : Option < Specialization < ' db > > ,
2813-
28142789 /// Information about which parameter(s) each argument was matched with, in argument source
28152790 /// order.
28162791 argument_matches : Box < [ MatchedArgument < ' db > ] > ,
@@ -2835,7 +2810,6 @@ impl<'db> Binding<'db> {
28352810 signature_type,
28362811 return_ty : Type :: unknown ( ) ,
28372812 specialization : None ,
2838- inherited_specialization : None ,
28392813 argument_matches : Box :: from ( [ ] ) ,
28402814 variadic_argument_matched_to_variadic_parameter : false ,
28412815 parameter_tys : Box :: from ( [ ] ) ,
@@ -2906,15 +2880,10 @@ impl<'db> Binding<'db> {
29062880 checker. infer_specialization ( ) ;
29072881
29082882 checker. check_argument_types ( ) ;
2909- ( self . specialization , self . inherited_specialization ) = checker. finish ( ) ;
2883+ self . specialization = checker. finish ( ) ;
29102884 if let Some ( specialization) = self . specialization {
29112885 self . return_ty = self . return_ty . apply_specialization ( db, specialization) ;
29122886 }
2913- if let Some ( inherited_specialization) = self . inherited_specialization {
2914- self . return_ty = self
2915- . return_ty
2916- . apply_specialization ( db, inherited_specialization) ;
2917- }
29182887 }
29192888
29202889 pub ( crate ) fn set_return_type ( & mut self , return_ty : Type < ' db > ) {
@@ -2925,8 +2894,8 @@ impl<'db> Binding<'db> {
29252894 self . return_ty
29262895 }
29272896
2928- pub ( crate ) fn inherited_specialization ( & self ) -> Option < Specialization < ' db > > {
2929- self . inherited_specialization
2897+ pub ( crate ) fn specialization ( & self ) -> Option < Specialization < ' db > > {
2898+ self . specialization
29302899 }
29312900
29322901 /// Returns the bound types for each parameter, in parameter source order, or `None` if no
@@ -2988,7 +2957,6 @@ impl<'db> Binding<'db> {
29882957 BindingSnapshot {
29892958 return_ty : self . return_ty ,
29902959 specialization : self . specialization ,
2991- inherited_specialization : self . inherited_specialization ,
29922960 argument_matches : self . argument_matches . clone ( ) ,
29932961 parameter_tys : self . parameter_tys . clone ( ) ,
29942962 errors : self . errors . clone ( ) ,
@@ -2999,15 +2967,13 @@ impl<'db> Binding<'db> {
29992967 let BindingSnapshot {
30002968 return_ty,
30012969 specialization,
3002- inherited_specialization,
30032970 argument_matches,
30042971 parameter_tys,
30052972 errors,
30062973 } = snapshot;
30072974
30082975 self . return_ty = return_ty;
30092976 self . specialization = specialization;
3010- self . inherited_specialization = inherited_specialization;
30112977 self . argument_matches = argument_matches;
30122978 self . parameter_tys = parameter_tys;
30132979 self . errors = errors;
@@ -3027,7 +2993,6 @@ impl<'db> Binding<'db> {
30272993 fn reset ( & mut self ) {
30282994 self . return_ty = Type :: unknown ( ) ;
30292995 self . specialization = None ;
3030- self . inherited_specialization = None ;
30312996 self . argument_matches = Box :: from ( [ ] ) ;
30322997 self . parameter_tys = Box :: from ( [ ] ) ;
30332998 self . errors . clear ( ) ;
@@ -3038,7 +3003,6 @@ impl<'db> Binding<'db> {
30383003struct BindingSnapshot < ' db > {
30393004 return_ty : Type < ' db > ,
30403005 specialization : Option < Specialization < ' db > > ,
3041- inherited_specialization : Option < Specialization < ' db > > ,
30423006 argument_matches : Box < [ MatchedArgument < ' db > ] > ,
30433007 parameter_tys : Box < [ Option < Type < ' db > > ] > ,
30443008 errors : Vec < BindingError < ' db > > ,
@@ -3078,7 +3042,6 @@ impl<'db> CallableBindingSnapshot<'db> {
30783042 // ... and update the snapshot with the current state of the binding.
30793043 snapshot. return_ty = binding. return_ty ;
30803044 snapshot. specialization = binding. specialization ;
3081- snapshot. inherited_specialization = binding. inherited_specialization ;
30823045 snapshot
30833046 . argument_matches
30843047 . clone_from ( & binding. argument_matches ) ;
@@ -3373,7 +3336,7 @@ impl<'db> BindingError<'db> {
33733336 }
33743337 diag. info ( format_args ! (
33753338 " {}" ,
3376- overload. signature( context. db( ) , None ) . display( context. db( ) )
3339+ overload. signature( context. db( ) ) . display( context. db( ) )
33773340 ) ) ;
33783341 }
33793342 if overloads. len ( ) > MAXIMUM_OVERLOADS {
0 commit comments