@@ -28,11 +28,16 @@ module Impl {
2828 /** Gets the position of this type parameter. */
2929 int getPosition ( ) { this = any ( GenericParamList l ) .getTypeParam ( result ) }
3030
31- private int nrOfDirectTypeBounds ( ) {
32- result = this .getTypeBoundList ( ) .getNumberOfBounds ( )
33- or
34- not this .hasTypeBoundList ( ) and
35- result = 0
31+ private TypeBound getTypeBoundAt ( int i , int j ) {
32+ exists ( TypeBoundList tbl | result = tbl .getBound ( j ) |
33+ tbl = this .getTypeBoundList ( ) and i = 0
34+ or
35+ exists ( WherePred wp |
36+ wp = this .( TypeParamItemNode ) .getAWherePred ( ) and
37+ tbl = wp .getTypeBoundList ( ) and
38+ wp = any ( WhereClause wc ) .getPredicate ( i )
39+ )
40+ )
3641 }
3742
3843 /**
@@ -42,12 +47,7 @@ module Impl {
4247 * any `where` clauses for this type parameter.
4348 */
4449 TypeBound getTypeBound ( int index ) {
45- exists ( TypeBoundList tbl , int offset | result = tbl .getBound ( index - offset ) |
46- tbl = this .getTypeBoundList ( ) and offset = 0
47- or
48- tbl = this .( TypeParamItemNode ) .getAWherePred ( ) .getTypeBoundList ( ) and
49- offset = this .nrOfDirectTypeBounds ( )
50- )
50+ result = rank [ index + 1 ] ( int i , int j | | this .getTypeBoundAt ( i , j ) order by i , j )
5151 }
5252
5353 /**
@@ -56,7 +56,12 @@ module Impl {
5656 * This includes type bounds directly on this type parameter and bounds from
5757 * any `where` clauses for this type parameter.
5858 */
59- TypeBound getATypeBound ( ) { result = this .getTypeBound ( _) }
59+ TypeBound getATypeBound ( ) {
60+ // NOTE: This predicate is used in path resolution, so it can not be
61+ // defined using `getTypeBound` as that would cause non-monotonic
62+ // recursion due to the `rank`.
63+ result = this .getTypeBoundAt ( _, _)
64+ }
6065
6166 override string toAbbreviatedString ( ) { result = this .getName ( ) .getText ( ) }
6267
0 commit comments