Walk up the scope chain to determine if we're inside an async function. Annotation and TypeParams scopes act as async barriers (always non-async). Comprehension scopes are transparent (inherit parent's async context).
(&self)
| 1171 | /// Annotation and TypeParams scopes act as async barriers (always non-async). |
| 1172 | /// Comprehension scopes are transparent (inherit parent's async context). |
| 1173 | fn is_in_async_context(&self) -> bool { |
| 1174 | // Annotations are evaluated in a non-async scope even when |
| 1175 | // the enclosing function is async. |
| 1176 | if self.in_annotation { |
| 1177 | return false; |
| 1178 | } |
| 1179 | for table in self.tables.iter().rev() { |
| 1180 | match table.typ { |
| 1181 | CompilerScope::AsyncFunction => return true, |
| 1182 | CompilerScope::Function |
| 1183 | | CompilerScope::Lambda |
| 1184 | | CompilerScope::Class |
| 1185 | | CompilerScope::Module |
| 1186 | | CompilerScope::Annotation |
| 1187 | | CompilerScope::TypeParams => return false, |
| 1188 | // Comprehension inherits parent's async context |
| 1189 | CompilerScope::Comprehension => continue, |
| 1190 | } |
| 1191 | } |
| 1192 | false |
| 1193 | } |
| 1194 | |
| 1195 | fn line_index_start(&self, range: TextRange) -> u32 { |
| 1196 | self.source_file |
no test coverage detected