@@ -1354,7 +1354,7 @@ private module AssocFunctionResolution {
13541354 * `i`, and the type at position `posAdj` is `t`.
13551355 */
13561356 pragma [ nomagic]
1357- predicate assocFunctionInfo (
1357+ private predicate assocFunctionInfo (
13581358 Function f , string name , int arity , ImplOrTraitItemNode i , FunctionPosition posAdj ,
13591359 AssocFunctionType t
13601360 ) {
@@ -3087,59 +3087,17 @@ private class TupleLikeVariant extends TupleLikeConstructor instanceof Variant {
30873087}
30883088
30893089/**
3090- * A matching configuration for resolving types of tuple variants and tuple structs
3091- * such as `Result::Ok(42)`.
3090+ * A matching configuration for resolving types of tuple-like variants and tuple
3091+ * structs such as `Result::Ok(42)`.
30923092 */
30933093private module TupleLikeConstructionMatchingInput implements MatchingInputSig {
30943094 import FunctionPositionMatchingInput
30953095
3096- private newtype TDeclaration = TTupleLikeConstructorDeclaration ( TupleLikeConstructor tc )
3097-
3098- abstract class Declaration extends TDeclaration {
3099- abstract TypeParameter getTypeParameter ( TypeParameterPosition ppos ) ;
3100-
3101- pragma [ nomagic]
3102- abstract Type getParameterType ( DeclarationPosition dpos , TypePath path ) ;
3103-
3104- abstract Type getReturnType ( TypePath path ) ;
3105-
3106- Type getDeclaredType ( DeclarationPosition dpos , TypePath path ) {
3107- result = this .getParameterType ( dpos , path )
3108- or
3109- dpos .isReturn ( ) and
3110- result = this .getReturnType ( path )
3111- }
3112-
3113- abstract string toString ( ) ;
3114-
3115- abstract Location getLocation ( ) ;
3116- }
3117-
3118- private class TupleLikeConstructorDeclaration extends Declaration ,
3119- TTupleLikeConstructorDeclaration
3120- {
3121- TupleLikeConstructor tc ;
3122-
3123- TupleLikeConstructorDeclaration ( ) { this = TTupleLikeConstructorDeclaration ( tc ) }
3124-
3125- override TypeParameter getTypeParameter ( TypeParameterPosition ppos ) {
3126- result = tc .getTypeParameter ( ppos )
3127- }
3128-
3129- override Type getParameterType ( DeclarationPosition dpos , TypePath path ) {
3130- result = tc .getParameterType ( dpos , path )
3131- }
3132-
3133- override Type getReturnType ( TypePath path ) { result = tc .getReturnType ( path ) }
3134-
3135- override string toString ( ) { result = tc .toString ( ) }
3136-
3137- override Location getLocation ( ) { result = tc .getLocation ( ) }
3138- }
3096+ class Declaration = TupleLikeConstructor ;
31393097
31403098 class Access extends CallExpr , ContextTyping:: ContextTypedCallCand {
31413099 Access ( ) {
3142- forall ( ItemNode i | i = CallExprImpl:: getResolvedFunction ( this ) | not i instanceof Method )
3100+ forex ( ItemNode i | i = CallExprImpl:: getResolvedFunction ( this ) | not i instanceof Function )
31433101 }
31443102
31453103 pragma [ nomagic]
@@ -3162,27 +3120,17 @@ private module TupleLikeConstructionMatchingInput implements MatchingInputSig {
31623120 }
31633121
31643122 pragma [ nomagic]
3165- private ItemNode resolveCallTargetViaPathResolution ( ) {
3166- result = CallExprImpl:: getResolvedFunction ( this ) and
3167- not result instanceof AssocFunction
3168- }
3169-
3170- pragma [ inline]
3171- Declaration getTarget ( ) {
3172- exists ( ItemNode i | i = this .resolveCallTargetViaPathResolution ( ) |
3173- result = TTupleLikeConstructorDeclaration ( i )
3174- )
3175- }
3123+ Declaration getTarget ( ) { result = CallExprImpl:: getResolvedFunction ( this ) }
31763124
31773125 /**
3178- * Holds if the return type of this call at `path` may have to be inferred
3179- * from the context.
3126+ * Holds if the return type of this tuple-like construction at `path` may have to be inferred
3127+ * from the context, for example in `Result::Ok(42)` the error type has to be inferred from the
3128+ * context.
31803129 */
31813130 pragma [ nomagic]
31823131 predicate hasUnknownTypeAt ( FunctionPosition pos , TypePath path ) {
3183- // Tuple declarations, such as `Result::Ok(...)`, may also be context typed
31843132 exists ( TupleLikeConstructor tc , TypeParameter tp |
3185- tc = this .resolveCallTargetViaPathResolution ( ) and
3133+ tc = this .getTarget ( ) and
31863134 pos .isReturn ( ) and
31873135 tp = tc .getReturnType ( path ) and
31883136 not tp = tc .getParameterType ( _, _) and
0 commit comments