Skip to content

Commit d3803b0

Browse files
committed
Fix nested generic type qualified names
1 parent 99fe9d8 commit d3803b0

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

csharp/ql/src/semmle/code/csharp/Generics.qll

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,16 @@ class UnboundGenericType extends ValueOrRefType, UnboundGeneric {
124124
}
125125

126126
final override predicate hasQualifiedName(string qualifier, string name) {
127-
super.hasQualifiedName(qualifier, _) and
128-
name = this.getNameWithoutBrackets() + "<" + this.getTypeParameterCommas() + ">"
127+
exists(string name0 | name = name0 + "<" + this.getTypeParameterCommas() + ">" |
128+
exists(string enclosing |
129+
this.getDeclaringType().hasQualifiedName(qualifier, enclosing) and
130+
name0 = enclosing + "+" + this.getNameWithoutBrackets()
131+
)
132+
or
133+
not exists(this.getDeclaringType()) and
134+
qualifier = this.getNamespace().getQualifiedName() and
135+
name0 = this.getNameWithoutBrackets()
136+
)
129137
}
130138
}
131139

@@ -406,10 +414,15 @@ class ConstructedType extends ValueOrRefType, ConstructedGeneric {
406414
}
407415

408416
final override predicate hasQualifiedName(string qualifier, string name) {
409-
exists(string undecorated |
410-
super.hasQualifiedName(qualifier, _) and
411-
types(this, _, undecorated) and
412-
name = undecorated + "<" + this.getTypeArgumentsQualifiedNames() + ">"
417+
exists(string name0 | name = name0 + "<" + this.getTypeArgumentsQualifiedNames() + ">" |
418+
exists(string enclosing |
419+
this.getDeclaringType().hasQualifiedName(qualifier, enclosing) and
420+
name0 = enclosing + "+" + this.getNameWithoutBrackets()
421+
)
422+
or
423+
not exists(this.getDeclaringType()) and
424+
qualifier = this.getNamespace().getQualifiedName() and
425+
name0 = this.getNameWithoutBrackets()
413426
)
414427
}
415428
}

0 commit comments

Comments
 (0)