@@ -47,6 +47,18 @@ class UnboundGeneric extends DotNet::UnboundGeneric, Generic {
4747 }
4848}
4949
50+ /** Gets the type parameters as a comma-separated string. */
51+ language [ monotonicAggregates]
52+ private string getTypeParametersToString ( UnboundGeneric ug ) {
53+ result =
54+ strictconcat ( Type t , int i | t = ug .getTypeParameter ( i ) | t .toStringWithTypes ( ) , ", " order by i )
55+ }
56+
57+ /** Gets a string of `N` commas where `N + 1` is the number of type parameters of this unbound generic. */
58+ private string getTypeParameterCommas ( UnboundGeneric ug ) {
59+ result = strictconcat ( int i | exists ( ug .getTypeParameter ( i ) ) | "" , "," )
60+ }
61+
5062/**
5163 * A constructed generic.
5264 *
@@ -72,6 +84,26 @@ class ConstructedGeneric extends DotNet::ConstructedGeneric, Generic {
7284 final AnnotatedType getAnnotatedTypeArgument ( int i ) { result .appliesToTypeArgument ( this , i ) }
7385}
7486
87+ /** Gets the type arguments as a comma-separated string. */
88+ language [ monotonicAggregates]
89+ private string getTypeArgumentsToString ( ConstructedGeneric cg ) {
90+ result =
91+ strictconcat ( Type t , int i | t = cg .getTypeArgument ( i ) | t .toStringWithTypes ( ) , ", " order by i )
92+ }
93+
94+ /** Gets the concatenation of the `getName()` of type arguments. */
95+ language [ monotonicAggregates]
96+ private string getTypeArgumentsNames ( ConstructedGeneric cg ) {
97+ result = strictconcat ( Type t , int i | t = cg .getTypeArgument ( i ) | t .getName ( ) , "," order by i )
98+ }
99+
100+ /** Gets the concatenation of the `getQualifiedName()` of type arguments. */
101+ language [ monotonicAggregates]
102+ private string getTypeArgumentsQualifiedNames ( ConstructedGeneric cg ) {
103+ result =
104+ strictconcat ( Type t , int i | t = cg .getTypeArgument ( i ) | t .getQualifiedName ( ) , "," order by i )
105+ }
106+
75107/**
76108 * An unbound generic type. This is a generic type with type parameters
77109 * (for example `List<T>`) or elided type parameters (for example `List<>`).
@@ -111,20 +143,16 @@ class UnboundGenericType extends ValueOrRefType, UnboundGeneric {
111143
112144 final override Type getChild ( int n ) { result = getTypeParameter ( n ) }
113145
114- private string getTypeParameterCommas ( ) {
115- result = strictconcat ( int i | exists ( this .getTypeParameter ( i ) ) | "" , "," )
116- }
117-
118146 override string toStringWithTypes ( ) {
119- result = this .getUndecoratedName ( ) + "<" + this . typeParametersToString ( ) + ">"
147+ result = this .getUndecoratedName ( ) + "<" + getTypeParametersToString ( this ) + ">"
120148 }
121149
122150 final override string getName ( ) {
123- result = this .getUndecoratedName ( ) + "<" + this . getTypeParameterCommas ( ) + ">"
151+ result = this .getUndecoratedName ( ) + "<" + getTypeParameterCommas ( this ) + ">"
124152 }
125153
126154 final override predicate hasQualifiedName ( string qualifier , string name ) {
127- exists ( string name0 | name = name0 + "<" + this . getTypeParameterCommas ( ) + ">" |
155+ exists ( string name0 | name = name0 + "<" + getTypeParameterCommas ( this ) + ">" |
128156 exists ( string enclosing |
129157 this .getDeclaringType ( ) .hasQualifiedName ( qualifier , enclosing ) and
130158 name0 = enclosing + "+" + this .getUndecoratedName ( )
@@ -348,8 +376,8 @@ class UnboundGenericDelegateType extends DelegateType, UnboundGenericType {
348376
349377 override string toStringWithTypes ( ) {
350378 result =
351- getUndecoratedName ( ) + "<" + this . typeParametersToString ( ) + ">(" + parameterTypesToString ( ) +
352- ")"
379+ getUndecoratedName ( ) + "<" + getTypeParametersToString ( this ) + ">(" + parameterTypesToString ( )
380+ + ")"
353381 }
354382}
355383
@@ -378,37 +406,16 @@ class ConstructedType extends ValueOrRefType, ConstructedGeneric {
378406
379407 final override Type getChild ( int n ) { result = getTypeArgument ( n ) }
380408
381- language [ monotonicAggregates]
382- private string getTypeArgumentsString ( ) {
383- result =
384- strictconcat ( Type t , int i | t = this .getTypeArgument ( i ) | t .toString ( ) , ", " order by i )
385- }
386-
387- language [ monotonicAggregates]
388- private string getTypeArgumentsNames ( ) {
389- result = strictconcat ( Type t , int i | t = this .getTypeArgument ( i ) | t .getName ( ) , "," order by i )
390- }
391-
392- language [ monotonicAggregates]
393- private string getTypeArgumentsQualifiedNames ( ) {
394- result =
395- strictconcat ( Type t , int i |
396- t = this .getTypeArgument ( i )
397- |
398- t .getQualifiedName ( ) , "," order by i
399- )
400- }
401-
402409 final override string toStringWithTypes ( ) {
403- result = this .getUndecoratedName ( ) + "<" + this . getTypeArgumentsString ( ) + ">"
410+ result = this .getUndecoratedName ( ) + "<" + getTypeArgumentsToString ( this ) + ">"
404411 }
405412
406413 final override string getName ( ) {
407- result = this .getUndecoratedName ( ) + "<" + this . getTypeArgumentsNames ( ) + ">"
414+ result = this .getUndecoratedName ( ) + "<" + getTypeArgumentsNames ( this ) + ">"
408415 }
409416
410417 final override predicate hasQualifiedName ( string qualifier , string name ) {
411- exists ( string name0 | name = name0 + "<" + this . getTypeArgumentsQualifiedNames ( ) + ">" |
418+ exists ( string name0 | name = name0 + "<" + getTypeArgumentsQualifiedNames ( this ) + ">" |
412419 exists ( string enclosing |
413420 this .getDeclaringType ( ) .hasQualifiedName ( qualifier , enclosing ) and
414421 name0 = enclosing + "+" + this .getUndecoratedName ( )
@@ -535,8 +542,15 @@ class UnboundGenericMethod extends Method, UnboundGeneric {
535542
536543 override string toStringWithTypes ( ) {
537544 result =
538- getName ( ) + "<" + this .typeParametersToString ( ) + ">" + "(" + parameterTypesToString ( ) + ")"
545+ getUndecoratedName ( ) + "<" + getTypeParametersToString ( this ) + ">" + "(" +
546+ parameterTypesToString ( ) + ")"
547+ }
548+
549+ final override string getName ( ) {
550+ result = getUndecoratedName ( ) + "<" + getTypeParameterCommas ( this ) + ">"
539551 }
552+
553+ final override string getUndecoratedName ( ) { methods ( this , result , _, _, _) }
540554}
541555
542556/**
@@ -566,12 +580,24 @@ class ConstructedMethod extends Method, ConstructedGeneric {
566580
567581 override string toStringWithTypes ( ) {
568582 result =
569- getName ( ) + "<" + this .typeArgumentsToString ( ) + ">" + "(" + parameterTypesToString ( ) + ")"
583+ getUndecoratedName ( ) + "<" + getTypeArgumentsToString ( this ) + ">" + "(" +
584+ parameterTypesToString ( ) + ")"
570585 }
571586
572587 override UnboundGenericMethod getUnboundDeclaration ( ) {
573588 result = Method .super .getUnboundDeclaration ( )
574589 }
590+
591+ final override string getName ( ) {
592+ result = getUndecoratedName ( ) + "<" + getTypeArgumentsNames ( this ) + ">"
593+ }
594+
595+ override predicate hasQualifiedName ( string qualifier , string name ) {
596+ qualifier = getDeclaringType ( ) .getQualifiedName ( ) and
597+ name = getUndecoratedName ( ) + "<" + getTypeArgumentsQualifiedNames ( this ) + ">"
598+ }
599+
600+ final override string getUndecoratedName ( ) { methods ( this , result , _, _, _) }
575601}
576602
577603/**
0 commit comments