@@ -2409,16 +2409,28 @@ private module AssocFunctionResolution {
24092409 predicate hasNoInherentTarget ( ) {
24102410 afc_ .hasTrait ( )
24112411 or
2412- exists ( TypePath strippedTypePath , Type strippedType , string name , int arity |
2412+ exists (
2413+ TypePath strippedTypePath , Type strippedType , string name , int arity ,
2414+ TypeOption typeQualifier , TypeOption traitQualifier , boolean hasReceiver
2415+ |
2416+ // Calls to inherent functions are always of the form `x.m(...)` or `Foo::bar(...)`,
2417+ // where `Foo` is a type. In case `bar` is a method, we can use both the type qualifier
2418+ // and the type of the first argument to rule out candidates
2419+ selfPosAdj_ .isTypeQualifier ( ) and hasReceiver = false
2420+ or
2421+ selfPosAdj_ .asPosition ( ) = 0 and hasReceiver = true
2422+ |
2423+ callInfo ( afc_ , name , arity , typeQualifier , traitQualifier , _) and
24132424 this .hasSignature ( _, selfPosAdj_ , strippedTypePath , strippedType , name , arity ) and
24142425 forall ( Impl i |
2426+ i .isInherent ( ) and
24152427 (
2416- assocFunctionInfoNonBlanketLike ( _, name , arity , selfPosAdj_ , i , _, strippedTypePath ,
2417- strippedType , _ , _ , _ ) or
2418- assocFunctionInfoNonBlanketLikeTypeParam ( _ , name , arity , selfPosAdj_ , i , _ ,
2419- strippedTypePath , _ , _ , _)
2420- ) and
2421- i . isInherent ( )
2428+ assocFunctionInfoNonBlanketLikeCand ( _, name , arity , selfPosAdj_ , i , _, strippedTypePath ,
2429+ strippedType , typeQualifier , traitQualifier , hasReceiver )
2430+ or
2431+ assocFunctionInfoNonBlanketLikeTypeParamCand ( _ , name , arity , selfPosAdj_ , i , _,
2432+ strippedTypePath , typeQualifier , traitQualifier , hasReceiver )
2433+ )
24222434 |
24232435 this .hasIncompatibleInherentTarget ( i )
24242436 )
@@ -2654,7 +2666,13 @@ private module AssocFunctionResolution {
26542666 AssocFunctionCallCand afcc , TypeAbstraction abs , AssocFunctionType constraint
26552667 ) {
26562668 SelfArgIsInstantiationOfInput:: potentialInstantiationOf0 ( afcc , abs , constraint ) and
2657- abs .( Impl ) .isInherent ( )
2669+ abs .( Impl ) .isInherent ( ) and
2670+ exists ( AssocFunctionCall afc , FunctionPosition selfPosAdj |
2671+ afcc = MkAssocFunctionCallCand ( afc , selfPosAdj , _, _)
2672+ |
2673+ selfPosAdj .isTypeQualifier ( ) or
2674+ afc .hasReceiverPos ( selfPosAdj )
2675+ )
26582676 }
26592677 }
26602678
0 commit comments