@@ -195,6 +195,12 @@ module API {
195195 */
196196 Node getReturn ( ) { result = this .getASuccessor ( Label:: return ( ) ) }
197197
198+ /**
199+ * Gets a node representing instances of the class represented by this node, as specified via
200+ * type annotations.
201+ */
202+ Node getInstanceFromAnnotation ( ) { result = this .getASuccessor ( Label:: annotation ( ) ) }
203+
198204 /**
199205 * Gets a node representing the `i`th parameter of the function represented by this node.
200206 *
@@ -229,7 +235,9 @@ module API {
229235 /**
230236 * Gets a node representing an instance of the class (or a transitive subclass of the class) represented by this node.
231237 */
232- Node getAnInstance ( ) { result = this .getASubclass * ( ) .getReturn ( ) }
238+ Node getAnInstance ( ) {
239+ result in [ this .getASubclass * ( ) .getReturn ( ) , this .getASubclass * ( ) .getInstanceFromAnnotation ( ) ]
240+ }
233241
234242 /**
235243 * Gets a node representing the result from awaiting this node.
@@ -834,6 +842,10 @@ module API {
834842 lbl = Label:: return ( ) and
835843 ref = pred .getACall ( )
836844 or
845+ // Getting an instance via a type annotation
846+ lbl = Label:: annotation ( ) and
847+ ref = pred .getAnAnnotatedInstance ( )
848+ or
837849 // Awaiting a node that is a use of `base`
838850 lbl = Label:: await ( ) and
839851 ref = pred .getAnAwaited ( )
@@ -1079,6 +1091,7 @@ module API {
10791091 } or
10801092 MkLabelSelfParameter ( ) or
10811093 MkLabelReturn ( ) or
1094+ MkLabelAnnotation ( ) or
10821095 MkLabelSubclass ( ) or
10831096 MkLabelAwait ( ) or
10841097 MkLabelSubscript ( ) or
@@ -1148,6 +1161,11 @@ module API {
11481161 override string toString ( ) { result = "getReturn()" }
11491162 }
11501163
1164+ /** A label for annotations. */
1165+ class LabelAnnotation extends ApiLabel , MkLabelAnnotation {
1166+ override string toString ( ) { result = "getAnnotatedInstance()" }
1167+ }
1168+
11511169 /** A label that gets the subclass of a class. */
11521170 class LabelSubclass extends ApiLabel , MkLabelSubclass {
11531171 override string toString ( ) { result = "getASubclass()" }
@@ -1207,6 +1225,9 @@ module API {
12071225 /** Gets the `return` edge label. */
12081226 LabelReturn return ( ) { any ( ) }
12091227
1228+ /** Gets the `annotation` edge label. */
1229+ LabelAnnotation annotation ( ) { any ( ) }
1230+
12101231 /** Gets the `subclass` edge label. */
12111232 LabelSubclass subclass ( ) { any ( ) }
12121233
0 commit comments