@@ -1258,6 +1258,14 @@ impl<'db> Type<'db> {
12581258 ) => ( self . literal_fallback_instance ( db) )
12591259 . is_some_and ( |instance| instance. is_subtype_of ( db, target) ) ,
12601260
1261+ // Function-like callables are subtypes of `FunctionType`
1262+ ( Type :: Callable ( callable) , Type :: NominalInstance ( target) )
1263+ if callable. is_function_like ( db)
1264+ && target. class . is_known ( db, KnownClass :: FunctionType ) =>
1265+ {
1266+ true
1267+ }
1268+
12611269 ( Type :: FunctionLiteral ( self_function_literal) , Type :: Callable ( _) ) => {
12621270 self_function_literal
12631271 . into_callable_type ( db)
@@ -6933,7 +6941,7 @@ impl<'db> FunctionType<'db> {
69336941 Type :: Callable ( CallableType :: from_overloads (
69346942 db,
69356943 self . signature ( db) . overloads . iter ( ) . cloned ( ) ,
6936- true ,
6944+ false ,
69376945 ) )
69386946 }
69396947
@@ -7754,6 +7762,15 @@ impl<'db> CallableType<'db> {
77547762 where
77557763 F : Fn ( & Signature < ' db > , & Signature < ' db > ) -> bool ,
77567764 {
7765+ dbg ! ( self ) ;
7766+ dbg ! ( other) ;
7767+ let self_is_function_like = self . is_function_like ( db) ;
7768+ let other_is_function_like = other. is_function_like ( db) ;
7769+
7770+ if !self_is_function_like && other_is_function_like {
7771+ return false ;
7772+ }
7773+
77577774 match ( self . signatures ( db) , other. signatures ( db) ) {
77587775 ( [ self_signature] , [ other_signature] ) => {
77597776 // Base case: both callable types contain a single signature.
@@ -7796,6 +7813,10 @@ impl<'db> CallableType<'db> {
77967813 ///
77977814 /// See [`Type::is_equivalent_to`] for more details.
77987815 fn is_equivalent_to ( self , db : & ' db dyn Db , other : Self ) -> bool {
7816+ if self . is_function_like ( db) != other. is_function_like ( db) {
7817+ return false ;
7818+ }
7819+
77997820 match ( self . signatures ( db) , other. signatures ( db) ) {
78007821 ( [ self_signature] , [ other_signature] ) => {
78017822 // Common case: both callable types contain a single signature, use the custom
@@ -7822,6 +7843,10 @@ impl<'db> CallableType<'db> {
78227843 ///
78237844 /// See [`Type::is_gradual_equivalent_to`] for more details.
78247845 fn is_gradual_equivalent_to ( self , db : & ' db dyn Db , other : Self ) -> bool {
7846+ if self . is_function_like ( db) != other. is_function_like ( db) {
7847+ return false ;
7848+ }
7849+
78257850 match ( self . signatures ( db) , other. signatures ( db) ) {
78267851 ( [ self_signature] , [ other_signature] ) => {
78277852 self_signature. is_gradual_equivalent_to ( db, other_signature)
0 commit comments