@@ -23,6 +23,10 @@ class FunctionPosition extends TFunctionPosition {
2323
2424 ArgumentPosition asArgumentPosition ( ) { this = TArgumentFunctionPosition ( result ) }
2525
26+ predicate isTypeQualifier ( ) { this .asArgumentPosition ( ) .isTypeQualifier ( ) }
27+
28+ predicate isSelfOrTypeQualifier ( ) { this .isSelf ( ) or this .isTypeQualifier ( ) }
29+
2630 predicate isReturn ( ) { this = TReturnFunctionPosition ( ) }
2731
2832 /** Gets the corresponding position when `f` is invoked via a function call. */
@@ -82,9 +86,9 @@ private newtype TAssocFunctionType =
8286 // through `i`. This ensures that `parent` is either a supertrait of `i` or
8387 // `i` in an `impl` block implementing `parent`.
8488 ( parent = i or BaseTypes:: rootTypesSatisfaction ( _, TTrait ( parent ) , i , _, _) ) and
85- // We always include the `self` position, even for non-methods, where it is used
89+ // We always include the type qualifer position, even for non-methods, where it is used
8690 // to match type qualifiers against the `impl` or trait type, such as in `Vec::new`.
87- ( exists ( pos .getTypeMention ( f ) ) or pos .isSelf ( ) )
91+ ( exists ( pos .getTypeMention ( f ) ) or pos .isTypeQualifier ( ) )
8892 }
8993
9094bindingset [ abs, constraint, tp]
@@ -116,21 +120,9 @@ Type getAssocFunctionTypeAt(Function f, ImplOrTraitItemNode i, FunctionPosition
116120 else result = getTraitConstraintTypeAt ( i , constraint , tp , suffix )
117121 )
118122 )
119- }
120-
121- /**
122- * Same as `getAssocFunctionTypeAt`, but also includes types at the `self` position
123- * for non-methods.
124- */
125- pragma [ nomagic]
126- Type getAssocFunctionTypeInclNonMethodSelfAt (
127- Function f , ImplOrTraitItemNode i , FunctionPosition pos , TypePath path
128- ) {
129- result = getAssocFunctionTypeAt ( f , i , pos , path )
130123 or
131124 f = i .getASuccessor ( _) and
132- not f .hasSelfParam ( ) and
133- pos .isSelf ( ) and
125+ pos .isTypeQualifier ( ) and
134126 result = resolveImplOrTraitType ( i , path )
135127}
136128
@@ -192,7 +184,7 @@ class AssocFunctionType extends MkAssocFunctionType {
192184 Type getTypeAt ( TypePath path ) {
193185 exists ( Function f , FunctionPosition pos , ImplOrTraitItemNode i , Type t |
194186 this .appliesTo ( f , i , pos ) and
195- t = getAssocFunctionTypeInclNonMethodSelfAt ( f , i , pos , path )
187+ t = getAssocFunctionTypeAt ( f , i , pos , path )
196188 |
197189 not t instanceof SelfTypeParameter and
198190 result = t
0 commit comments