@@ -2593,21 +2593,32 @@ private Type inferMethodCallTypeSelf(
25932593 apos .isSelf ( )
25942594 )
25952595 or
2596+ // adjust for implicit borrow
25962597 exists ( TypePath path0 , BorrowKind borrow0 |
25972598 result = inferMethodCallTypeSelf ( n , derefChain , borrow0 , path0 ) and
2598- // adjust for implicit borrow
25992599 path0 .isCons ( borrow0 .getRefType ( ) .getPositionalTypeParameter ( 0 ) , path ) and
26002600 borrow .isNoBorrow ( )
26012601 )
26022602 or
2603- exists ( TypePath path0 |
2604- result = inferMethodCallTypeSelf ( n , derefChain , borrow , path0 ) and
2603+ // adjust for implicit deref
2604+ exists (
2605+ DerefChain derefChain0 , Type t0 , TypePath path0 , DerefImplItemNode impl , Type selfType ,
2606+ TypePath selfPath
2607+ |
2608+ t0 = inferMethodCallTypeSelf ( n , derefChain0 , borrow , path0 ) and
2609+ derefChain0 .isCons ( impl , derefChain ) and
26052610 borrow .isNoBorrow ( ) and
2606- // adjust for implicit deref
2607- exists ( DerefImplItemNode impl |
2608- impl .isRefImpl ( ) and
2609- derefChain = DerefChain:: singleton ( impl ) and
2610- path = TypePath:: cons ( getRefTypeParameter ( ) , path0 )
2611+ selfType = impl .resolveSelfParamTypeStrippedAt ( selfPath )
2612+ |
2613+ result = selfType and
2614+ path = selfPath and
2615+ not result instanceof TypeParameter
2616+ or
2617+ exists ( TypeParameter tp , TypePath pathToTypeParam , TypePath suffix |
2618+ impl .returnTypeStrippedMentionsTypeParameterAt ( tp , pathToTypeParam ) and
2619+ path0 = pathToTypeParam .appendInverse ( suffix ) and
2620+ result = t0 and
2621+ path = selfPath .append ( suffix )
26112622 )
26122623 )
26132624}
0 commit comments