@@ -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- 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
156+ TMethodEntityElement ( Method m , string pkg , string type , boolean subtypes ) {
157+ m .hasQualifiedName ( pkg , type , _) and
158+ subtypes = [ true , false ]
159+ } or
160+ TFieldEntityElement ( Field f , string pkg , string type , boolean subtypes ) {
161+ f .hasQualifiedName ( pkg , type , _) and
161162 subtypes = [ true , false ]
162163 } or
163164 TOtherEntityElement ( Entity e ) {
@@ -170,10 +171,15 @@ module SourceSinkInterpretationInput implements
170171 class SourceOrSinkElement extends TSourceOrSinkElement {
171172 /** Gets this source or sink element as an entity, if it is one. */
172173 Entity asEntity ( ) {
173- this = TMethodOrFieldEntityElement ( result , _, _, _) or
174- this = TOtherEntityElement ( result )
174+ result = [ this .asMethodEntity ( ) , this .asFieldEntity ( ) , this .asOtherEntity ( ) ]
175175 }
176176
177+ Method asMethodEntity ( ) { this = TMethodEntityElement ( result , _, _, _) }
178+
179+ Field asFieldEntity ( ) { this = TFieldEntityElement ( result , _, _, _) }
180+
181+ Entity asOtherEntity ( ) { this = TOtherEntityElement ( result ) }
182+
177183 /** Gets this source or sink element as an AST node, if it is one. */
178184 AstNode asAstNode ( ) { this = TAstElement ( result ) }
179185
@@ -182,7 +188,8 @@ module SourceSinkInterpretationInput implements
182188 * with the given values for `pkg`, `type` and `subtypes`.
183189 */
184190 predicate hasTypeInfo ( string pkg , string type , boolean subtypes ) {
185- this = TMethodOrFieldEntityElement ( _, pkg , type , subtypes )
191+ this = TMethodEntityElement ( _, pkg , type , subtypes ) or
192+ this = TFieldEntityElement ( _, pkg , type , subtypes )
186193 }
187194
188195 /** Gets a textual representation of this source or sink element. */
@@ -239,11 +246,10 @@ module SourceSinkInterpretationInput implements
239246 cn = this .asCall ( ) .getNode ( ) and
240247 callTarget = cn .getTarget ( )
241248 |
242- result .asEntity ( ) = callTarget and
243249 (
244- not callTarget instanceof Method
250+ result . asOtherEntity ( ) = callTarget
245251 or
246- callTarget instanceof Method and
252+ result . asMethodEntity ( ) = callTarget and
247253 elementAppliesToQualifier ( result , cn .getReceiver ( ) )
248254 )
249255 )
@@ -302,7 +308,7 @@ module SourceSinkInterpretationInput implements
302308 // `syntacticQualBaseType`'s underlying type might be a struct type and `sse`
303309 // might be a promoted method or field in it.
304310 targetType =
305- getIntermediateEmbeddedType ( sse .asEntity ( ) , syntacticQualBaseType .getUnderlyingType ( ) )
311+ getIntermediateEmbeddedType ( sse .asMethodEntity ( ) , syntacticQualBaseType .getUnderlyingType ( ) )
306312 )
307313 )
308314 }
@@ -382,7 +388,7 @@ module SourceSinkInterpretationInput implements
382388 or
383389 exists ( DataFlow:: FieldReadNode frn | frn = n |
384390 c = "" and
385- frn .getField ( ) = pragma [ only_bind_into ] ( e ) .asEntity ( ) and
391+ frn .getField ( ) = pragma [ only_bind_into ] ( e ) .asFieldEntity ( ) and
386392 elementAppliesToQualifier ( pragma [ only_bind_into ] ( e ) , frn .getBase ( ) )
387393 )
388394 )
@@ -400,7 +406,7 @@ module SourceSinkInterpretationInput implements
400406 or
401407 exists ( SourceOrSinkElement e , DataFlow:: Write fw , DataFlow:: Node base , Field f |
402408 e = mid .asElement ( ) and
403- f = e .asEntity ( )
409+ f = e .asFieldEntity ( )
404410 |
405411 c = "" and
406412 fw .writesField ( base , f , node .asNode ( ) ) and
0 commit comments