@@ -143,7 +143,11 @@ class NonAliasPathTypeMention extends PathTypeMention {
143143 )
144144 }
145145
146- private TypeMention getPositionalTypeArgument0 ( int i ) {
146+ /**
147+ * Gets the positional type argument at index `i` that occurs in this path, if
148+ * any.
149+ */
150+ private TypeMention getPathPositionalTypeArgument ( int i ) {
147151 result = this .getSegment ( ) .getGenericArgList ( ) .getTypeArg ( i )
148152 or
149153 // `Option::<i32>::Some` is valid in addition to `Option::Some::<i32>`
@@ -155,7 +159,7 @@ class NonAliasPathTypeMention extends PathTypeMention {
155159 * Gets the type mention that instantiates the implicit `Self` type parameter
156160 * for this path, if it occurs in the position of a trait bound.
157161 */
158- private TypeMention getSelfTypeParameter ( ) {
162+ private TypeMention getSelfTraitBoundArg ( ) {
159163 exists ( ImplItemNode impl | this = impl .getTraitPath ( ) and result = impl .( Impl ) .getSelfTy ( ) )
160164 or
161165 exists ( Trait subTrait |
@@ -166,16 +170,10 @@ class NonAliasPathTypeMention extends PathTypeMention {
166170 exists ( TypeParamItemNode tp | this = tp .getABoundPath ( ) and result = tp )
167171 }
168172
169- private Type getPositionalTypeArgument ( int i , TypePath path ) {
170- result = this .getPositionalTypeArgument0 ( i ) .resolveTypeAt ( path )
171- or
172- result = this .getDefaultPositionalTypeArgument ( i , path )
173- }
174-
175173 private Type getDefaultPositionalTypeArgument ( int i , TypePath path ) {
176174 // If a type argument is not given in the path, then we use the default for
177175 // the type parameter if one exists for the type.
178- not exists ( this .getPositionalTypeArgument0 ( i ) ) and
176+ not exists ( this .getPathPositionalTypeArgument ( i ) ) and
179177 // Defaults only apply to type mentions in type annotations
180178 this = any ( PathTypeRepr ptp ) .getPath ( ) .getQualifier * ( ) and
181179 exists ( Type ty , TypePath prefix |
@@ -187,11 +185,17 @@ class NonAliasPathTypeMention extends PathTypeMention {
187185 // be substituted for the type that implements the trait.
188186 exists ( TypePath suffix |
189187 path = prefix .append ( suffix ) and
190- result = this .getSelfTypeParameter ( ) .resolveTypeAt ( suffix )
188+ result = this .getSelfTraitBoundArg ( ) .resolveTypeAt ( suffix )
191189 )
192190 )
193191 }
194192
193+ private Type getPositionalTypeArgument ( int i , TypePath path ) {
194+ result = this .getPathPositionalTypeArgument ( i ) .resolveTypeAt ( path )
195+ or
196+ result = this .getDefaultPositionalTypeArgument ( i , path )
197+ }
198+
195199 /**
196200 * Gets the type for this path for the type parameter `tp` at `path`, when the
197201 * type parameter does not correspond directly to a type mention.
@@ -282,7 +286,7 @@ class NonAliasPathTypeMention extends PathTypeMention {
282286 // When the path refers to a trait, then the implicit `Self` type parameter
283287 // should be instantiated from the context.
284288 exists ( TypePath suffix |
285- result = this .getSelfTypeParameter ( ) .resolveTypeAt ( suffix ) and
289+ result = this .getSelfTraitBoundArg ( ) .resolveTypeAt ( suffix ) and
286290 typePath = TypePath:: cons ( TSelfTypeParameter ( resolved ) , suffix )
287291 )
288292 }
0 commit comments