Skip to content

Commit 65ce8aa

Browse files
Fix issue with circular type bounds
1 parent 0577e12 commit 65ce8aa

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

java/ql/src/utils/Stubs.qll

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ abstract private class GeneratedType extends RefType {
4343
final string getStub() {
4444
result =
4545
this.stubAbstractModifier() + this.stubStaticModifier() + this.stubAccessibilityModifier() +
46-
this.stubKeyword() + " " + this.getName() + stubGenericArguments(this) +
46+
this.stubKeyword() + " " + this.getName() + stubGenericArguments(this, true) +
4747
stubBaseTypesString() + "\n{\n" + stubMembers() + "}"
4848
}
4949

@@ -225,7 +225,7 @@ private string stubTypeName(Type t) {
225225
then
226226
result =
227227
stubQualifier(t) + t.(RefType).getSourceDeclaration().getName() +
228-
stubGenericArguments(t)
228+
stubGenericArguments(t, false)
229229
else result = "<error>"
230230
}
231231

@@ -245,22 +245,34 @@ private string stubTypeBound(BoundedType t) {
245245
)
246246
}
247247

248+
private string maybeStubTypeBound(BoundedType t, boolean typeVarBounds) {
249+
typeVarBounds = true and
250+
result = stubTypeBound(t)
251+
or
252+
typeVarBounds = false and
253+
result = ""
254+
}
255+
248256
private string stubQualifier(RefType t) {
249257
if t instanceof NestedType
250-
then result = stubTypeName(t.(NestedType).getEnclosingType()) + "."
258+
then
259+
exists(RefType et | et = t.(NestedType).getEnclosingType().getSourceDeclaration() |
260+
result = stubQualifier(et) + et.getName() + "."
261+
)
251262
else result = ""
252263
}
253264

254265
language[monotonicAggregates]
255-
private string stubGenericArguments(RefType t) {
266+
private string stubGenericArguments(RefType t, boolean typeVarBounds) {
267+
typeVarBounds = [true, false] and
256268
if t instanceof GenericType
257269
then
258270
result =
259271
"<" +
260272
concat(int n, TypeVariable tv |
261273
tv = t.(GenericType).getTypeParameter(n)
262274
|
263-
tv.getName() + stubTypeBound(tv), ", " order by n
275+
tv.getName() + maybeStubTypeBound(tv, typeVarBounds), ", " order by n
264276
) + ">"
265277
else
266278
if t instanceof ParameterizedType

0 commit comments

Comments
 (0)