@@ -56,6 +56,32 @@ class PathTypeReprMention extends TypeMention instanceof PathTypeRepr {
5656
5757 ItemNode getResolved ( ) { result = resolved }
5858
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+ exists ( AssocTypeArg arg |
71+ arg = path .getSegment ( ) .getGenericArgList ( ) .getAGenericArg ( ) and
72+ result = arg .getTypeRepr ( name )
73+ )
74+ }
75+
76+ /** Gets the type argument for the associated type `alias`, if any. */
77+ pragma [ nomagic]
78+ private TypeRepr getAnAssocTypeArgument ( TypeAlias alias ) {
79+ exists ( string name |
80+ alias = this .getResolvedTraitAlias ( name ) and
81+ result = this .getAssocTypeArg ( name )
82+ )
83+ }
84+
5985 override TypeMention getTypeArgument ( int i ) {
6086 result = path .getSegment ( ) .getGenericArgList ( ) .getTypeArg ( i )
6187 or
@@ -96,6 +122,11 @@ class PathTypeReprMention extends TypeMention instanceof PathTypeRepr {
96122 result = alias .getTypeRepr ( ) and
97123 param .getIndex ( ) = i
98124 )
125+ or
126+ exists ( TypeAlias alias |
127+ result = this .getAnAssocTypeArgument ( alias ) and
128+ traitAliasIndex ( _, i , alias )
129+ )
99130 }
100131
101132 /**
@@ -150,44 +181,6 @@ class PathTypeReprMention extends TypeMention instanceof PathTypeRepr {
150181 not exists ( resolved .( TypeAlias ) .getTypeRepr ( ) ) and
151182 result = super .resolveTypeAt ( typePath )
152183 }
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- }
191184}
192185
193186class ImplTraitTypeReprMention extends TypeMention instanceof ImplTraitTypeRepr {
0 commit comments