Skip to content

Commit 1188e1b

Browse files
committed
Fix extra constructor stubbing
1 parent 2dc0849 commit 1188e1b

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

csharp/ql/src/Stubs/Stubs.qll

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,23 @@ abstract private class GeneratedType extends Type, GeneratedElement {
186186

187187
string stubPrivateConstructor() {
188188
if
189-
this instanceof Interface or
190-
this.isStatic() or
191-
this.isAbstract() or
192-
exists(this.(ValueOrRefType).getAConstructor()) or
193-
not exists(this.getAnInterestingBaseType()) or
194-
not exists(this.getAnInterestingBaseType().getAConstructor()) or
195-
this.getAnInterestingBaseType().getAConstructor().getNumberOfParameters() = 0
189+
this instanceof Interface
190+
or
191+
this.isStatic()
192+
or
193+
this.isAbstract()
194+
or
195+
exists(this.(ValueOrRefType).getAConstructor())
196+
or
197+
not exists(this.getAnInterestingBaseType())
198+
or
199+
not exists(this.getAnInterestingBaseType().getAConstructor())
200+
or
201+
exists(Constructor bc |
202+
bc = this.getAnInterestingBaseType().getAConstructor() and
203+
bc.getNumberOfParameters() = 0 and
204+
not bc.isStatic()
205+
)
196206
then result = ""
197207
else
198208
result =
@@ -287,7 +297,9 @@ private class ExtraGeneratedConstructor extends GeneratedMember, Constructor {
287297
(
288298
// if the base class has no 0 parameter constructor
289299
not exists(Constructor c |
290-
c = this.getDeclaringType().getBaseClass().getAMember() and c.getNumberOfParameters() = 0
300+
c = this.getDeclaringType().getBaseClass().getAMember() and
301+
c.getNumberOfParameters() = 0 and
302+
not c.isStatic()
291303
)
292304
or
293305
// if this constructor might be called from a (generic) derived class

0 commit comments

Comments
 (0)