Skip to content

Commit fd0b16b

Browse files
committed
Fix class instance method detection in constructor receiver
1 parent 2842804 commit fd0b16b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

javascript/ql/lib/semmle/javascript/dataflow/Nodes.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,9 @@ module ClassNode {
14531453
accessor.getName() = name and
14541454
result = accessor.getInit().flow()
14551455
)
1456+
or
1457+
kind = MemberKind::method() and
1458+
result = this.getConstructor().getReceiver().getAPropertySource(name)
14561459
}
14571460

14581461
override FunctionNode getAnInstanceMember(MemberKind kind) {
@@ -1485,6 +1488,9 @@ module ClassNode {
14851488
accessor = this.getAnAccessor(kind) and
14861489
result = accessor.getInit().flow()
14871490
)
1491+
or
1492+
kind = MemberKind::method() and
1493+
result = this.getConstructor().getReceiver().getAPropertySource()
14881494
}
14891495

14901496
override FunctionNode getStaticMember(string name, MemberKind kind) {

javascript/ql/test/library-tests/CallGraphs/AnnotatedTest/Test.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ spuriousCallee
22
missingCallee
33
| constructor-field.ts:40:5:40:14 | f3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 | calls |
44
| constructor-field.ts:71:1:71:11 | bf3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 | calls |
5-
| prototypes.js:117:5:117:19 | this.tmpClass() | prototypes.js:113:1:113:22 | functio ... ss() {} | -1 | calls |
6-
| prototypes.js:131:5:131:23 | this.tmpPrototype() | prototypes.js:127:1:127:26 | functio ... pe() {} | -1 | calls |
75
badAnnotation
86
accessorCall
97
| accessors.js:12:1:12:5 | obj.f | accessors.js:5:8:5:12 | () {} |

0 commit comments

Comments
 (0)