@@ -56,6 +56,29 @@ 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+ 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+
5982 override TypeMention getTypeArgument ( int i ) {
6083 result = path .getSegment ( ) .getGenericArgList ( ) .getTypeArg ( i )
6184 or
@@ -96,6 +119,11 @@ class PathTypeReprMention extends TypeMention instanceof PathTypeRepr {
96119 result = alias .getTypeRepr ( ) and
97120 param .getIndex ( ) = i
98121 )
122+ or
123+ exists ( TypeAlias alias |
124+ result = this .getAnAssocTypeArgument ( alias ) and
125+ traitAliasIndex ( _, i , alias )
126+ )
99127 }
100128
101129 /**
@@ -150,44 +178,6 @@ class PathTypeReprMention extends TypeMention instanceof PathTypeRepr {
150178 not exists ( resolved .( TypeAlias ) .getTypeRepr ( ) ) and
151179 result = super .resolveTypeAt ( typePath )
152180 }
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- }
191181}
192182
193183class ImplTraitTypeReprMention extends TypeMention instanceof ImplTraitTypeRepr {
0 commit comments