File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
test/library-tests/CallGraphs/AnnotatedTest Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,9 @@ module Public {
179
179
/** Holds if this represents values stored at an unknown array index. */
180
180
predicate isUnknownArrayElement ( ) { this = MkArrayElementUnknown ( ) }
181
181
182
+ /** Holds if this represents the value of a resolved promise. */
183
+ predicate isPromiseValue ( ) { this = MkPromiseValue ( ) }
184
+
182
185
/** Holds if this represents values stored in a `Map` at an unknown key. */
183
186
predicate isMapValueWithUnknownKey ( ) { this = MkMapValueWithUnknownKey ( ) }
184
187
@@ -266,6 +269,11 @@ module Public {
266
269
or
267
270
this = ContentSet:: anyCapturedContent ( ) and
268
271
result instanceof Private:: MkCapturedContent
272
+ or
273
+ // Although data flow will never use the special `Awaited` ContentSet in a read or store step,
274
+ // it may appear in type-tracking and type resolution, and here it helps to treat is as `Awaited[value]`.
275
+ this = MkAwaited ( ) and
276
+ result = MkPromiseValue ( )
269
277
}
270
278
271
279
/** Gets the singleton content to be accessed. */
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ module TypeResolution {
60
60
content .isUnknownArrayElement ( )
61
61
)
62
62
or
63
- // Ad-hoc support for array types. We don't support generics in general currently, we just special-case arrays.
63
+ // Ad-hoc support for array types. We don't support generics in general currently, we just special-case arrays and promises .
64
64
content .isUnknownArrayElement ( ) and
65
65
(
66
66
memberType = host .( ArrayTypeExpr ) .getElementType ( )
@@ -77,6 +77,9 @@ module TypeResolution {
77
77
memberType = type .getArgument ( 0 )
78
78
)
79
79
)
80
+ or
81
+ content .isPromiseValue ( ) and
82
+ memberType = unwrapPromiseType ( host )
80
83
}
81
84
82
85
/**
@@ -120,6 +123,9 @@ module TypeResolution {
120
123
object .( ObjectPattern ) .getPropertyPatternByName ( contents .asPropertyName ( ) ) .getValuePattern ( ) =
121
124
member
122
125
or
126
+ member .( AwaitExpr ) .getOperand ( ) = object and
127
+ contents = DataFlow:: ContentSet:: promiseValue ( )
128
+ or
123
129
SummaryTypeTracker:: basicLoadStep ( object .( AST:: ValueNode ) .flow ( ) ,
124
130
member .( AST:: ValueNode ) .flow ( ) , contents )
125
131
}
Original file line number Diff line number Diff line change @@ -14,3 +14,14 @@ function t1(c: NS.C, d: NS.D) {
14
14
/** calls:NS.C.m */
15
15
d . m ( ) ;
16
16
}
17
+
18
+ async function t2 ( cp : Promise < NS . C > ) {
19
+ const c = await cp ;
20
+ /** calls:NS.C.m */
21
+ c . m ( ) ;
22
+
23
+ cp . then ( c2 => {
24
+ /** calls:NS.C.m */
25
+ c2 . m ( ) ;
26
+ } )
27
+ }
You can’t perform that action at this time.
0 commit comments