@@ -1708,6 +1708,15 @@ private module AssocFunctionResolution {
17081708
17091709 predicate hasReceiverAtPos ( FunctionPosition pos ) { this .hasReceiver ( ) and pos .asPosition ( ) = 0 }
17101710
1711+ pragma [ nomagic]
1712+ private predicate hasIncompatibleArgsTarget (
1713+ ImplOrTraitItemNode i , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow ,
1714+ AssocFunctionType selfType
1715+ ) {
1716+ SelfArgIsInstantiationOf:: argIsInstantiationOf ( this , i , selfPos , derefChain , borrow , selfType ) and
1717+ OverloadedCallArgsAreInstantiationsOf:: argsAreNotInstantiationsOf ( this , i )
1718+ }
1719+
17111720 /**
17121721 * Holds if the function inside `i` with matching name and arity can be ruled
17131722 * out as a target of this call, because the candidate receiver type represented
@@ -1722,16 +1731,11 @@ private module AssocFunctionResolution {
17221731 ImplOrTraitItemNode i , FunctionPosition selfPos , DerefChain derefChain , BorrowKind borrow ,
17231732 Type root
17241733 ) {
1725- exists ( TypePath path |
1726- SelfArgIsInstantiationOf:: argIsNotInstantiationOf ( this , i , selfPos , derefChain , borrow , path ) and
1727- path .isCons ( root .getATypeParameter ( ) , _)
1728- )
1729- or
1730- exists ( AssocFunctionType selfType |
1731- SelfArgIsInstantiationOf:: argIsInstantiationOf ( this , i , selfPos , derefChain , borrow ,
1732- selfType ) and
1733- OverloadedCallArgsAreInstantiationsOf:: argsAreNotInstantiationsOf ( this , i ) and
1734- root = selfType .getTypeAt ( TypePath:: nil ( ) )
1734+ exists ( AssocFunctionType selfType | root = selfType .getTypeAt ( TypePath:: nil ( ) ) |
1735+ this .hasIncompatibleArgsTarget ( i , selfPos , derefChain , borrow , selfType )
1736+ or
1737+ SelfArgIsInstantiationOf:: argIsNotInstantiationOf ( this , i , selfPos , derefChain , borrow ,
1738+ selfType )
17351739 )
17361740 }
17371741
@@ -2608,9 +2612,13 @@ private module AssocFunctionResolution {
26082612 pragma [ nomagic]
26092613 predicate argIsNotInstantiationOf (
26102614 AssocFunctionCall afc , ImplOrTraitItemNode i , FunctionPosition selfPos , DerefChain derefChain ,
2611- BorrowKind borrow , TypePath path
2615+ BorrowKind borrow , AssocFunctionType selfType
26122616 ) {
2613- argIsNotInstantiationOf ( MkAssocFunctionCallCand ( afc , selfPos , derefChain , borrow ) , i , _, path )
2617+ exists ( TypePath path |
2618+ argIsNotInstantiationOf ( MkAssocFunctionCallCand ( afc , selfPos , derefChain , borrow ) , i ,
2619+ selfType , path ) and
2620+ not path .isEmpty ( )
2621+ )
26142622 }
26152623
26162624 pragma [ nomagic]
0 commit comments