@@ -2604,37 +2604,39 @@ private Type inferMethodCallTypeNonSelf(AstNode n, boolean isReturn, TypePath pa
26042604}
26052605
26062606/**
2607- * Gets the type of `n` at `path` after applying `derefChain` and `borrow`,
2608- * where `n` is the `self` argument of a method call.
2607+ * Gets the type of `n` at `path` after applying `derefChain`, where `n` is the
2608+ * `self` argument of a method call.
26092609 *
26102610 * The predicate recursively pops the head of `derefChain` until it becomes
26112611 * empty, at which point the inferred type can be applied back to `n`.
26122612 */
26132613pragma [ nomagic]
2614- private Type inferMethodCallTypeSelf (
2615- AstNode n , DerefChain derefChain , BorrowKind borrow , TypePath path
2616- ) {
2617- exists ( MethodCallMatchingInput:: AccessPosition apos , string derefChainBorrow |
2618- result = inferMethodCallType0 ( _, apos , n , derefChainBorrow , path ) and
2614+ private Type inferMethodCallTypeSelf ( AstNode n , DerefChain derefChain , TypePath path ) {
2615+ exists (
2616+ MethodCallMatchingInput:: AccessPosition apos , string derefChainBorrow , BorrowKind borrow ,
2617+ TypePath path0
2618+ |
2619+ result = inferMethodCallType0 ( _, apos , n , derefChainBorrow , path0 ) and
26192620 apos .isSelf ( ) and
26202621 MethodCallMatchingInput:: decodeDerefChainBorrow ( derefChainBorrow , derefChain , borrow )
2621- )
2622- or
2623- // adjust for implicit borrow
2624- exists ( TypePath path0 , BorrowKind borrow0 |
2625- result = inferMethodCallTypeSelf ( n , derefChain , borrow0 , path0 ) and
2626- path0 .isCons ( borrow0 .getRefType ( ) .getPositionalTypeParameter ( 0 ) , path ) and
2627- borrow .isNoBorrow ( )
2622+ |
2623+ borrow .isNoBorrow ( ) and
2624+ path = path0
2625+ or
2626+ // adjust for implicit borrow
2627+ exists ( TypePath prefix |
2628+ prefix = TypePath:: singleton ( borrow .getRefType ( ) .getPositionalTypeParameter ( 0 ) ) and
2629+ path0 = prefix .appendInverse ( path )
2630+ )
26282631 )
26292632 or
26302633 // adjust for implicit deref
26312634 exists (
26322635 DerefChain derefChain0 , Type t0 , TypePath path0 , DerefImplItemNode impl , Type selfParamType ,
26332636 TypePath selfPath
26342637 |
2635- t0 = inferMethodCallTypeSelf ( n , derefChain0 , borrow , path0 ) and
2638+ t0 = inferMethodCallTypeSelf ( n , derefChain0 , path0 ) and
26362639 derefChain0 .isCons ( impl , derefChain ) and
2637- borrow .isNoBorrow ( ) and
26382640 selfParamType = impl .resolveSelfTypeAt ( selfPath )
26392641 |
26402642 result = selfParamType and
@@ -2653,7 +2655,7 @@ private Type inferMethodCallTypeSelf(
26532655private Type inferMethodCallTypePreCheck ( AstNode n , boolean isReturn , TypePath path ) {
26542656 result = inferMethodCallTypeNonSelf ( n , isReturn , path )
26552657 or
2656- result = inferMethodCallTypeSelf ( n , DerefChain:: nil ( ) , TNoBorrowKind ( ) , path ) and
2658+ result = inferMethodCallTypeSelf ( n , DerefChain:: nil ( ) , path ) and
26572659 isReturn = false
26582660}
26592661
0 commit comments