@@ -56,6 +56,29 @@ class PathTypeReprMention extends TypeMention instanceof PathTypeRepr {
56
56
57
57
ItemNode getResolved ( ) { result = resolved }
58
58
59
+ pragma [ nomagic]
60
+ private TypeAlias getResolvedTraitAlias ( string name ) {
61
+ exists ( TraitItemNode trait |
62
+ trait = resolvePath ( path ) and
63
+ result = trait .getAnAssocItem ( ) and
64
+ name = result .getName ( ) .getText ( )
65
+ )
66
+ }
67
+
68
+ pragma [ nomagic]
69
+ private TypeRepr getAssocTypeArg ( string name ) {
70
+ result = path .getSegment ( ) .getGenericArgList ( ) .getAssocTypeArg ( name )
71
+ }
72
+
73
+ /** Gets the type argument for the associated type `alias`, if any. */
74
+ pragma [ nomagic]
75
+ private TypeRepr getAnAssocTypeArgument ( TypeAlias alias ) {
76
+ exists ( string name |
77
+ alias = this .getResolvedTraitAlias ( name ) and
78
+ result = this .getAssocTypeArg ( name )
79
+ )
80
+ }
81
+
59
82
override TypeMention getTypeArgument ( int i ) {
60
83
result = path .getSegment ( ) .getGenericArgList ( ) .getTypeArg ( i )
61
84
or
@@ -96,6 +119,11 @@ class PathTypeReprMention extends TypeMention instanceof PathTypeRepr {
96
119
result = alias .getTypeRepr ( ) and
97
120
param .getIndex ( ) = i
98
121
)
122
+ or
123
+ exists ( TypeAlias alias |
124
+ result = this .getAnAssocTypeArgument ( alias ) and
125
+ traitAliasIndex ( _, i , alias )
126
+ )
99
127
}
100
128
101
129
/**
@@ -150,44 +178,6 @@ class PathTypeReprMention extends TypeMention instanceof PathTypeRepr {
150
178
not exists ( resolved .( TypeAlias ) .getTypeRepr ( ) ) and
151
179
result = super .resolveTypeAt ( typePath )
152
180
}
153
-
154
- pragma [ nomagic]
155
- private TypeAlias getResolvedTraitAlias ( string name ) {
156
- exists ( TraitItemNode trait |
157
- trait = resolvePath ( path ) and
158
- result = trait .getAnAssocItem ( ) and
159
- name = result .getName ( ) .getText ( )
160
- )
161
- }
162
-
163
- pragma [ nomagic]
164
- private TypeRepr getAssocTypeArg ( string name ) {
165
- exists ( AssocTypeArg arg |
166
- arg = path .getSegment ( ) .getGenericArgList ( ) .getAGenericArg ( ) and
167
- result = arg .getTypeRepr ( ) and
168
- name = arg .getIdentifier ( ) .getText ( )
169
- )
170
- }
171
-
172
- /** Gets the type argument for the associated type `alias`, if any. */
173
- pragma [ nomagic]
174
- private TypeRepr getAnAssocTypeArgument ( TypeAlias alias ) {
175
- exists ( string name |
176
- alias = this .getResolvedTraitAlias ( name ) and
177
- result = this .getAssocTypeArg ( name )
178
- )
179
- }
180
-
181
- override TypeMention getMentionAt ( TypePath tp ) {
182
- result = super .getMentionAt ( tp )
183
- or
184
- exists ( TypeAlias alias , AssociatedTypeTypeParameter attp , TypeMention arg , TypePath suffix |
185
- arg = this .getAnAssocTypeArgument ( alias ) and
186
- result = arg .getMentionAt ( suffix ) and
187
- tp = TypePath:: cons ( attp , suffix ) and
188
- attp .getTypeAlias ( ) = alias
189
- )
190
- }
191
181
}
192
182
193
183
class ImplTraitTypeReprMention extends TypeMention instanceof ImplTraitTypeRepr {
0 commit comments