@@ -59,12 +59,7 @@ module Impl {
5959 Expr getReceiver ( ) { result = this .getArgument ( TSelfArgumentPosition ( ) ) }
6060
6161 /** Gets the static target of this call, if any. */
62- Function getStaticTarget ( ) {
63- result = TypeInference:: resolveMethodCallTarget ( this )
64- or
65- not exists ( TypeInference:: resolveMethodCallTarget ( this ) ) and
66- result = this .( CallExpr ) .getStaticTarget ( )
67- }
62+ Function getStaticTarget ( ) { result = TypeInference:: resolveCallTarget ( this ) }
6863
6964 /** Gets a runtime target of this call, if any. */
7065 pragma [ nomagic]
@@ -79,18 +74,23 @@ module Impl {
7974 }
8075
8176 /** Holds if the call expression dispatches to a method. */
82- private predicate callIsMethodCall ( CallExpr call , Path qualifier , string methodName ) {
77+ private predicate callIsMethodCall (
78+ CallExpr call , Path qualifier , string methodName , boolean selfIsRef
79+ ) {
8380 exists ( Path path , Function f |
8481 path = call .getFunction ( ) .( PathExpr ) .getPath ( ) and
8582 f = resolvePath ( path ) and
86- f .getParamList ( ) .hasSelfParam ( ) and
8783 qualifier = path .getQualifier ( ) and
88- path .getSegment ( ) .getIdentifier ( ) .getText ( ) = methodName
84+ path .getSegment ( ) .getIdentifier ( ) .getText ( ) = methodName and
85+ exists ( SelfParam self |
86+ self = f .getParamList ( ) .getSelfParam ( ) and
87+ if self .isRef ( ) then selfIsRef = true else selfIsRef = false
88+ )
8989 )
9090 }
9191
9292 private class CallExprCall extends Call instanceof CallExpr {
93- CallExprCall ( ) { not callIsMethodCall ( this , _, _) }
93+ CallExprCall ( ) { not callIsMethodCall ( this , _, _, _ ) }
9494
9595 override string getMethodName ( ) { none ( ) }
9696
@@ -103,11 +103,19 @@ module Impl {
103103 }
104104 }
105105
106- private class CallExprMethodCall extends Call instanceof CallExpr {
106+ class CallExprMethodCall extends Call instanceof CallExpr {
107107 Path qualifier ;
108108 string methodName ;
109+ boolean selfIsRef ;
110+
111+ CallExprMethodCall ( ) { callIsMethodCall ( this , qualifier , methodName , selfIsRef ) }
109112
110- CallExprMethodCall ( ) { callIsMethodCall ( this , qualifier , methodName ) }
113+ /**
114+ * Holds if this call must have an explicit borrow for the `self` argument,
115+ * because the corresponding parameter is `&self`. Explicit borrows are not
116+ * needed when using method call syntax.
117+ */
118+ predicate hasExplicitSelfBorrow ( ) { selfIsRef = true }
111119
112120 override string getMethodName ( ) { result = methodName }
113121
0 commit comments