@@ -3522,12 +3522,27 @@ private module Cached {
35223522 any ( MethodResolution:: MethodCall mc ) .argumentHasImplicitBorrow ( n )
35233523 }
35243524
3525- /** Gets an item (function or tuple struct/variant) that `call` resolves to, if any. */
3525+ /**
3526+ * Gets an item (function or tuple struct/variant) that `call` resolves to, if
3527+ * any.
3528+ *
3529+ * The parameter `dispatch` is `true` if and only if the resolved target is a
3530+ * trait item because the a precise target could not be determined from the
3531+ * types (for instance in the presence of generics or `dyn` types)
3532+ */
35263533 cached
3527- Addressable resolveCallTarget ( Expr call ) {
3528- result = call .( MethodResolution:: MethodCall ) .resolveCallTarget ( _, _, _)
3534+ Addressable resolveCallTarget ( Call call , boolean dispatch ) {
3535+ dispatch = false and
3536+ result = call .( NonMethodResolution:: NonMethodCall ) .resolveCallTargetViaPathResolution ( )
35293537 or
3530- result = call .( NonMethodResolution:: NonMethodCall ) .resolveCallTarget ( )
3538+ exists ( ImplOrTraitItemNode i |
3539+ i instanceof TraitItemNode and dispatch = true
3540+ or
3541+ i instanceof ImplItemNode and dispatch = false
3542+ |
3543+ result = call .( MethodResolution:: MethodCall ) .resolveCallTarget ( i , _, _) or
3544+ result = call .( NonMethodResolution:: NonMethodCall ) .resolveCallTargetViaTypeInference ( i )
3545+ )
35313546 }
35323547
35333548 /**
@@ -3668,9 +3683,17 @@ private module Debug {
36683683 result = inferType ( n , path )
36693684 }
36703685
3671- Addressable debugResolveCallTarget ( InvocationExpr c ) {
3686+ Addressable debugResolveCallTarget ( InvocationExpr c , boolean dispatch ) {
36723687 c = getRelevantLocatable ( ) and
3673- result = resolveCallTarget ( c )
3688+ result = resolveCallTarget ( c , dispatch )
3689+ }
3690+
3691+ Addressable debugMethodResolveCallTarget ( Call call , ImplOrTraitItemNode i ) {
3692+ // call = getRelevantLocatable() and
3693+ // result = call.(MethodResolution::MethodCall).resolveCallTarget(i, derefChain, borrow)
3694+ not call .isInMacroExpansion ( ) and
3695+ not i .getAnAssocItem ( ) = result and
3696+ result = call .( NonMethodResolution:: NonMethodCall ) .resolveCallTargetViaTypeInference ( i )
36743697 }
36753698
36763699 predicate debugConditionSatisfiesConstraint (
0 commit comments