@@ -580,7 +580,7 @@ private module Input3 implements InputSig3 {
580580
581581 Operator getTarget ( ) {
582582 exists ( ImplOrTraitItemNode i |
583- result .isAssocFunction ( i , this .resolveCallTarget ( i , _, _, _) , false ) // mutual recursion
583+ result .isFunction ( this .resolveCallTarget ( i , _, _, _) , false ) // mutual recursion
584584 )
585585 }
586586 }
@@ -1051,8 +1051,10 @@ private class FunctionDeclaration extends Function {
10511051 Type getParameterType ( ImplOrTraitItemNodeOption i , int pos , TypePath path ) {
10521052 i = parent and
10531053 exists ( FunctionPosition fpos | pos = fpos .asPosition ( ) |
1054+ // exists(i.asSome()) and
10541055 result = getAssocFunctionTypeAt ( this , i .asSome ( ) , fpos , path )
10551056 or
1057+ // result = fpos.getTypeMention(this).getTypeAt(path)
10561058 i .isNone ( ) and
10571059 result = this .getParam ( pos ) .getTypeRepr ( ) .( TypeMention ) .getTypeAt ( path )
10581060 )
@@ -1083,6 +1085,19 @@ private class FunctionDeclaration extends Function {
10831085 else result = this .resolveRetType ( i , path )
10841086 }
10851087
1088+ Type getReturnType2 ( TypePath path ) {
1089+ if this .isAsync ( )
1090+ then
1091+ path .isEmpty ( ) and
1092+ result = getFutureTraitType ( )
1093+ or
1094+ exists ( TypePath suffix |
1095+ result = getReturnTypeMention ( this ) .getTypeAt ( suffix ) and
1096+ path = TypePath:: cons ( getDynFutureOutputTypeParameter ( ) , suffix )
1097+ )
1098+ else result = getReturnTypeMention ( this ) .getTypeAt ( path )
1099+ }
1100+
10861101 string toStringExt ( ImplOrTraitItemNode i ) {
10871102 i = parent .asSome ( ) and
10881103 if this = i .getAnAssocItem ( )
@@ -2830,8 +2845,7 @@ private module AssocFunctionResolution {
28302845 */
28312846private module FunctionCallMatchingInput {
28322847 private newtype TDeclaration =
2833- TFunctionDeclaration ( ImplOrTraitItemNodeOption i , FunctionDeclaration f , boolean forIndexExpr ) {
2834- f .isFor ( i ) and
2848+ TFunctionDeclaration ( FunctionDeclaration f , boolean forIndexExpr ) {
28352849 (
28362850 forIndexExpr = false
28372851 or
@@ -2848,35 +2862,40 @@ private module FunctionCallMatchingInput {
28482862 }
28492863
28502864 final class Declaration extends TFunctionDeclaration {
2851- ImplOrTraitItemNodeOption i ;
28522865 FunctionDeclaration f ;
28532866 boolean forIndexExpr ;
28542867
2855- Declaration ( ) { this = TFunctionDeclaration ( i , f , forIndexExpr ) }
2868+ Declaration ( ) { this = TFunctionDeclaration ( f , forIndexExpr ) }
28562869
28572870 FunctionDeclaration getFunction ( ) { result = f }
28582871
2859- predicate isFunction ( ImplOrTraitItemNodeOption i_ , Function f_ ) {
2860- i_ = i and
2861- f_ = f
2862- }
2863-
2864- predicate isAssocFunction ( ImplOrTraitItemNode i_ , Function f_ , boolean forIndexExpr_ ) {
2865- i_ = i .asSome ( ) and
2872+ // predicate isFunction(ImplOrTraitItemNodeOption i_, Function f_) {
2873+ // i_ = i and
2874+ // f_ = f
2875+ // }
2876+ predicate isFunction ( Function f_ , boolean forIndexExpr_ ) {
28662877 f_ = f and
28672878 forIndexExpr_ = forIndexExpr
28682879 }
28692880
28702881 TypeParameter getTypeParameter ( TypeParameterPosition ppos ) {
2871- result = f .getTypeParameter ( i , ppos )
2882+ exists ( ImplOrTraitItemNodeOption i | result = f .getTypeParameter ( i , ppos ) |
2883+ i .isNone ( )
2884+ or
2885+ i .asSome ( ) .getAnAssocItem ( ) = f
2886+ )
28722887 }
28732888
2874- Type getParameterType ( int j , TypePath path ) { result = f .getParameterType ( i , j , path ) }
2889+ Type getParameterType ( int j , TypePath path ) {
2890+ exists ( FunctionPosition fpos | j = fpos .asPosition ( ) |
2891+ result = fpos .getTypeMention ( f ) .getTypeAt ( path )
2892+ )
2893+ }
28752894
28762895 Type getReturnType ( TypePath path ) {
28772896 // index expression `x[i]` desugars to `*x.index(i)`, so we must account for
28782897 // the implicit deref
2879- exists ( TypePath path0 | result = f .getReturnType ( i , path0 ) |
2898+ exists ( TypePath path0 | result = f .getReturnType2 ( path0 ) |
28802899 forIndexExpr = true and
28812900 path0 .isCons ( getRefTypeParameter ( _) , path )
28822901 or
@@ -2885,11 +2904,7 @@ private module FunctionCallMatchingInput {
28852904 )
28862905 }
28872906
2888- string toString ( ) {
2889- i .isNone ( ) and result = f .toString ( )
2890- or
2891- result = f .toStringExt ( i .asSome ( ) )
2892- }
2907+ string toString ( ) { result = f .toString ( ) }
28932908
28942909 Location getLocation ( ) { result = f .getLocation ( ) }
28952910 }
@@ -3010,7 +3025,7 @@ private module FunctionCallMatchingInput {
30103025
30113026 override Declaration getTarget ( string derefChainBorrow ) {
30123027 exists ( ImplOrTraitItemNode i , boolean forIndexExpr |
3013- result .isAssocFunction ( i , this .getTarget ( i , derefChainBorrow ) , forIndexExpr ) and
3028+ result .isFunction ( this .getTarget ( i , derefChainBorrow ) , forIndexExpr ) and
30143029 if this instanceof IndexExpr then forIndexExpr = true else forIndexExpr = false
30153030 )
30163031 }
@@ -3066,9 +3081,7 @@ private module FunctionCallMatchingInput {
30663081
30673082 pragma [ nomagic]
30683083 private Declaration getTarget ( ) {
3069- result =
3070- TFunctionDeclaration ( ImplOrTraitItemNodeOption:: none_ ( ) ,
3071- super .resolveCallTargetViaPathResolution ( ) , false )
3084+ result = TFunctionDeclaration ( super .resolveCallTargetViaPathResolution ( ) , false )
30723085 }
30733086
30743087 override Declaration getTarget ( string derefChainBorrow ) {
0 commit comments