Skip to content

Commit 520acc4

Browse files
smowtonowen-mc
authored andcommitted
Further simplify interpretElement to avoid 'm' only being used on one side of a disjunction
1 parent d9126d3 commit 520acc4

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

go/ql/lib/semmle/go/dataflow/ExternalFlow.qll

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -475,23 +475,21 @@ SourceSinkInterpretationInput::SourceOrSinkElement interpretElement(
475475
// Go does not need to distinguish functions with signature
476476
signature = "" and
477477
exists(string p | p = interpretPackage(pkg) |
478-
result.asEntity().(Field).hasQualifiedName(p, type, name) and
479-
result.hasTypeInfo(p, type, subtypes)
478+
result.hasTypeInfo(p, type, subtypes) and
479+
(
480+
result.asEntity().(Field).hasQualifiedName(p, type, name) or
481+
result.asEntity().(Method).hasQualifiedName(p, type, name)
482+
)
480483
or
481-
exists(Method m | m.hasQualifiedName(p, type, name) |
482-
result.asEntity() = m and
483-
result.hasTypeInfo(p, type, subtypes)
484-
or
485-
subtypes = true and
486-
// p.type is an interface and we include types which implement it
487-
exists(Method m2, string pkg2, string type2 |
488-
m2.getReceiverType().implements(p, type) and
489-
m2.getName() = name and
490-
m2.getReceiverBaseType().hasQualifiedName(pkg2, type2)
491-
|
492-
result.asEntity() = m2 and
493-
result.hasTypeInfo(pkg2, type2, subtypes)
494-
)
484+
subtypes = true and
485+
// p.type is an interface and we include types which implement it
486+
exists(Method m2, string pkg2, string type2 |
487+
m2.getReceiverType().implements(p, type) and
488+
m2.getName() = name and
489+
m2.getReceiverBaseType().hasQualifiedName(pkg2, type2)
490+
|
491+
result.asEntity() = m2 and
492+
result.hasTypeInfo(pkg2, type2, subtypes)
495493
)
496494
or
497495
type = "" and

0 commit comments

Comments
 (0)