@@ -1630,12 +1630,32 @@ private module AssocFunctionResolution {
16301630 }
16311631
16321632 /**
1633- * Same as `getTypeAt`, but without borrows.
1633+ * Holds if `selfPos` is a potentially relevant position for resolving this call.
1634+ */
1635+ pragma [ nomagic]
1636+ private predicate isRelevantSelfPos ( FunctionPosition selfPos ) {
1637+ exists ( TypePath strippedTypePath , Type strippedType |
1638+ strippedType = substituteLookupTraits ( this .getTypeAt ( selfPos , strippedTypePath ) )
1639+ |
1640+ selfPos .isSelfOrTypeQualifier ( )
1641+ or
1642+ not this .hasReceiver ( ) and
1643+ (
1644+ blanketLikeCandidate ( this , _, _, selfPos , _, _, _, _)
1645+ or
1646+ nonBlanketCandidate ( this , _, _, selfPos , _, _, strippedTypePath , strippedType )
1647+ )
1648+ )
1649+ }
1650+
1651+ /**
1652+ * Same as `getSelfTypeAt`, but without borrows.
16341653 */
16351654 pragma [ nomagic]
16361655 Type getSelfTypeAtNoBorrow ( FunctionPosition selfPos , DerefChain derefChain , TypePath path ) {
16371656 result = this .getTypeAt ( selfPos , path ) and
1638- derefChain .isEmpty ( )
1657+ derefChain .isEmpty ( ) and
1658+ this .isRelevantSelfPos ( selfPos )
16391659 or
16401660 exists ( DerefImplItemNode impl , DerefChain suffix |
16411661 result =
@@ -2627,37 +2647,29 @@ private module MethodCallMatchingInput implements MatchingWithEnvironmentInputSi
26272647 }
26282648
26292649 pragma [ nomagic]
2630- private Type getInferredSelfType (
2631- FunctionPosition pos , AccessPosition apos , string derefChainBorrow , TypePath path
2632- ) {
2650+ private Type getInferredSelfType ( FunctionPosition pos , string derefChainBorrow , TypePath path ) {
26332651 exists ( DerefChain derefChain , BorrowKind borrow |
26342652 result = this .getSelfTypeAt ( pos , derefChain , borrow , path ) and
26352653 derefChainBorrow = encodeDerefChainBorrow ( pos , derefChain , borrow ) and
2636- if this .hasReceiver ( ) then apos = pos else pos = apos .getFunctionCallAdjusted ( )
2654+ pos .isSelf ( )
2655+ // if this.hasReceiver() then apos = pos else pos = apos.getFunctionCallAdjusted()
26372656 )
26382657 }
26392658
26402659 pragma [ nomagic]
2641- private Type getInferredNonSelfType ( FunctionPosition pos , AccessPosition apos , TypePath path ) {
2642- exists ( DerefChain derefChain , BorrowKind borrow |
2643- result = this .getSelfTypeAt ( pos , derefChain , borrow , path ) and
2644- derefChain .isEmpty ( ) and
2645- borrow .isNoBorrow ( ) and
2660+ private Type getInferredNonSelfType ( AccessPosition apos , TypePath path ) {
2661+ exists ( FunctionPosition pos |
2662+ result = this .getTypeAt ( pos , path ) and
2663+ not pos .isSelf ( ) and
26462664 if this .hasReceiver ( ) then apos = pos else pos = apos .getFunctionCallAdjusted ( )
26472665 )
26482666 }
26492667
26502668 bindingset [ derefChainBorrow]
26512669 Type getInferredType ( string derefChainBorrow , AccessPosition apos , TypePath path ) {
2652- exists ( FunctionPosition pos |
2653- result = this .getInferredSelfType ( pos , apos , derefChainBorrow , path )
2654- or
2655- exists ( FunctionPosition selfPos |
2656- MethodCallMatchingInput:: decodeDerefChainBorrow ( derefChainBorrow , selfPos , _, _) and
2657- result = this .getInferredNonSelfType ( pos , apos , path ) and
2658- pos != selfPos
2659- )
2660- )
2670+ result = this .getInferredSelfType ( apos , derefChainBorrow , path )
2671+ or
2672+ result = this .getInferredNonSelfType ( apos , path )
26612673 }
26622674
26632675 Method getTarget ( ImplOrTraitItemNode i , string derefChainBorrow ) {
0 commit comments