Skip to content

Commit 8abb059

Browse files
committed
Combine two arms of newtype TSourceOrSinkElement
1 parent b2c2a94 commit 8abb059

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

go/ql/lib/semmle/go/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,12 @@ module SourceSinkInterpretationInput implements
153153
// Methods having multiple qualified names, a given Method is liable to have
154154
// more than one SourceOrSinkElement, one for each of the names it claims.
155155
private newtype TSourceOrSinkElement =
156-
TMethodEntityElement(Method m, string pkg, string type, boolean subtypes) {
157-
m.hasQualifiedName(pkg, type, _) and subtypes = [true, false]
158-
} or
159-
TFieldEntityElement(Field f, string pkg, string type, boolean subtypes) {
160-
f.hasQualifiedName(pkg, type, _) and subtypes = [true, false]
156+
TMethodOrFieldEntityElement(Entity e, string pkg, string type, boolean subtypes) {
157+
(
158+
e.(Method).hasQualifiedName(pkg, type, _) or
159+
e.(Field).hasQualifiedName(pkg, type, _)
160+
) and
161+
subtypes = [true, false]
161162
} or
162163
TOtherEntityElement(Entity e) {
163164
not e instanceof Method and
@@ -169,8 +170,7 @@ module SourceSinkInterpretationInput implements
169170
class SourceOrSinkElement extends TSourceOrSinkElement {
170171
/** Gets this source or sink element as an entity, if it is one. */
171172
Entity asEntity() {
172-
this = TMethodEntityElement(result, _, _, _) or
173-
this = TFieldEntityElement(result, _, _, _) or
173+
this = TMethodOrFieldEntityElement(result, _, _, _) or
174174
this = TOtherEntityElement(result)
175175
}
176176

@@ -182,8 +182,7 @@ module SourceSinkInterpretationInput implements
182182
* with the given values for `pkg`, `type` and `subtypes`.
183183
*/
184184
predicate hasTypeInfo(string pkg, string type, boolean subtypes) {
185-
this = TMethodEntityElement(_, pkg, type, subtypes) or
186-
this = TFieldEntityElement(_, pkg, type, subtypes)
185+
this = TMethodOrFieldEntityElement(_, pkg, type, subtypes)
187186
}
188187

189188
/** Gets a textual representation of this source or sink element. */

0 commit comments

Comments
 (0)