@@ -14,7 +14,7 @@ use crate::semantic_index::symbol::Symbol;
1414use crate :: semantic_index:: {
1515 DeclarationWithConstraint , SemanticIndex , attribute_declarations, attribute_scopes,
1616} ;
17- use crate :: types:: constraints:: { ConstraintSet , Constraints , IteratorConstraintsExtension } ;
17+ use crate :: types:: constraints:: { ConstraintSet , IteratorConstraintsExtension } ;
1818use crate :: types:: context:: InferContext ;
1919use crate :: types:: diagnostic:: { INVALID_LEGACY_TYPE_VARIABLE , INVALID_TYPE_ALIAS_TYPE } ;
2020use crate :: types:: enums:: enum_metadata;
@@ -524,46 +524,45 @@ impl<'db> ClassType<'db> {
524524
525525 /// Return `true` if `other` is present in this class's MRO.
526526 pub ( super ) fn is_subclass_of ( self , db : & ' db dyn Db , other : ClassType < ' db > ) -> bool {
527- self . when_subclass_of :: < ConstraintSet > ( db, other)
528- . is_always_satisfied ( db)
527+ self . when_subclass_of ( db, other) . is_always_satisfied ( )
529528 }
530529
531- pub ( super ) fn when_subclass_of < C : Constraints < ' db > > (
530+ pub ( super ) fn when_subclass_of (
532531 self ,
533532 db : & ' db dyn Db ,
534533 other : ClassType < ' db > ,
535- ) -> C {
534+ ) -> ConstraintSet < ' db > {
536535 self . has_relation_to_impl (
537536 db,
538537 other,
539538 TypeRelation :: Subtyping ,
540- & HasRelationToVisitor :: new ( C :: always_satisfiable ( db ) ) ,
539+ & HasRelationToVisitor :: default ( ) ,
541540 )
542541 }
543542
544- pub ( super ) fn has_relation_to_impl < C : Constraints < ' db > > (
543+ pub ( super ) fn has_relation_to_impl (
545544 self ,
546545 db : & ' db dyn Db ,
547546 other : Self ,
548547 relation : TypeRelation ,
549- visitor : & HasRelationToVisitor < ' db , C > ,
550- ) -> C {
548+ visitor : & HasRelationToVisitor < ' db > ,
549+ ) -> ConstraintSet < ' db > {
551550 self . iter_mro ( db) . when_any ( db, |base| {
552551 match base {
553552 ClassBase :: Dynamic ( _) => match relation {
554- TypeRelation :: Subtyping => C :: from_bool ( db , other. is_object ( db) ) ,
555- TypeRelation :: Assignability => C :: from_bool ( db , !other. is_final ( db) ) ,
553+ TypeRelation :: Subtyping => ConstraintSet :: from ( other. is_object ( db) ) ,
554+ TypeRelation :: Assignability => ConstraintSet :: from ( !other. is_final ( db) ) ,
556555 } ,
557556
558557 // Protocol and Generic are not represented by a ClassType.
559- ClassBase :: Protocol | ClassBase :: Generic => C :: unsatisfiable ( db ) ,
558+ ClassBase :: Protocol | ClassBase :: Generic => ConstraintSet :: from ( false ) ,
560559
561560 ClassBase :: Class ( base) => match ( base, other) {
562561 ( ClassType :: NonGeneric ( base) , ClassType :: NonGeneric ( other) ) => {
563- C :: from_bool ( db , base == other)
562+ ConstraintSet :: from ( base == other)
564563 }
565564 ( ClassType :: Generic ( base) , ClassType :: Generic ( other) ) => {
566- C :: from_bool ( db , base. origin ( db) == other. origin ( db) ) . and ( db, || {
565+ ConstraintSet :: from ( base. origin ( db) == other. origin ( db) ) . and ( db, || {
567566 base. specialization ( db) . has_relation_to_impl (
568567 db,
569568 other. specialization ( db) ,
@@ -573,34 +572,38 @@ impl<'db> ClassType<'db> {
573572 } )
574573 }
575574 ( ClassType :: Generic ( _) , ClassType :: NonGeneric ( _) )
576- | ( ClassType :: NonGeneric ( _) , ClassType :: Generic ( _) ) => C :: unsatisfiable ( db) ,
575+ | ( ClassType :: NonGeneric ( _) , ClassType :: Generic ( _) ) => {
576+ ConstraintSet :: from ( false )
577+ }
577578 } ,
578579
579580 ClassBase :: TypedDict => {
580581 // TODO: Implement subclassing and assignability for TypedDicts.
581- C :: always_satisfiable ( db )
582+ ConstraintSet :: from ( true )
582583 }
583584 }
584585 } )
585586 }
586587
587- pub ( super ) fn is_equivalent_to_impl < C : Constraints < ' db > > (
588+ pub ( super ) fn is_equivalent_to_impl (
588589 self ,
589590 db : & ' db dyn Db ,
590591 other : ClassType < ' db > ,
591- visitor : & IsEquivalentVisitor < ' db , C > ,
592- ) -> C {
592+ visitor : & IsEquivalentVisitor < ' db > ,
593+ ) -> ConstraintSet < ' db > {
593594 if self == other {
594- return C :: always_satisfiable ( db ) ;
595+ return ConstraintSet :: from ( true ) ;
595596 }
596597
597598 match ( self , other) {
598599 // A non-generic class is never equivalent to a generic class.
599600 // Two non-generic classes are only equivalent if they are equal (handled above).
600- ( ClassType :: NonGeneric ( _) , _) | ( _, ClassType :: NonGeneric ( _) ) => C :: unsatisfiable ( db) ,
601+ ( ClassType :: NonGeneric ( _) , _) | ( _, ClassType :: NonGeneric ( _) ) => {
602+ ConstraintSet :: from ( false )
603+ }
601604
602605 ( ClassType :: Generic ( this) , ClassType :: Generic ( other) ) => {
603- C :: from_bool ( db , this. origin ( db) == other. origin ( db) ) . and ( db, || {
606+ ConstraintSet :: from ( this. origin ( db) == other. origin ( db) ) . and ( db, || {
604607 this. specialization ( db) . is_equivalent_to_impl (
605608 db,
606609 other. specialization ( db) ,
@@ -1701,13 +1704,13 @@ impl<'db> ClassLiteral<'db> {
17011704 . contains ( & ClassBase :: Class ( other) )
17021705 }
17031706
1704- pub ( super ) fn when_subclass_of < C : Constraints < ' db > > (
1707+ pub ( super ) fn when_subclass_of (
17051708 self ,
17061709 db : & ' db dyn Db ,
17071710 specialization : Option < Specialization < ' db > > ,
17081711 other : ClassType < ' db > ,
1709- ) -> C {
1710- C :: from_bool ( db , self . is_subclass_of ( db, specialization, other) )
1712+ ) -> ConstraintSet < ' db > {
1713+ ConstraintSet :: from ( self . is_subclass_of ( db, specialization, other) )
17111714 }
17121715
17131716 /// Return `true` if this class constitutes a typed dict specification (inherits from
@@ -4360,12 +4363,12 @@ impl KnownClass {
43604363 . is_ok_and ( |class| class. is_subclass_of ( db, None , other) )
43614364 }
43624365
4363- pub ( super ) fn when_subclass_of < ' db , C : Constraints < ' db > > (
4366+ pub ( super ) fn when_subclass_of < ' db > (
43644367 self ,
43654368 db : & ' db dyn Db ,
43664369 other : ClassType < ' db > ,
4367- ) -> C {
4368- C :: from_bool ( db , self . is_subclass_of ( db, other) )
4370+ ) -> ConstraintSet < ' db > {
4371+ ConstraintSet :: from ( self . is_subclass_of ( db, other) )
43694372 }
43704373
43714374 /// Return the module in which we should look up the definition for this class
0 commit comments