Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4e0bbff

Browse files
committed
Fix ExtraGeneratedConstructor to exclude static constructors and take into account generic derived classes
1 parent e96754c commit 4e0bbff

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

csharp/ql/src/Stubs/Stubs.qll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ private class InheritedMember extends GeneratedMember, Virtualizable {
204204

205205
private class ExtraGeneratedConstructor extends GeneratedMember, Constructor {
206206
ExtraGeneratedConstructor() {
207+
not this.isStatic() and
207208
not this.isEffectivelyPublic() and
208209
this.getDeclaringType() instanceof GeneratedType and
209210
(
@@ -212,10 +213,10 @@ private class ExtraGeneratedConstructor extends GeneratedMember, Constructor {
212213
c = this.getDeclaringType().getBaseClass().getAMember() and c.getNumberOfParameters() = 0
213214
)
214215
or
215-
// if this constructor might be called from a derived class
216+
// if this constructor might be called from a (generic) derived class
216217
exists(Class c |
217-
c.getBaseClass() = this.getDeclaringType() and
218-
this = getBaseConstructor(c)
218+
this.getDeclaringType() = c.getBaseClass().getUnboundDeclaration() and
219+
this = getBaseConstructor(c).getUnboundDeclaration()
219220
)
220221
)
221222
}

0 commit comments

Comments
 (0)