File tree 1 file changed +16
-0
lines changed 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -312,6 +312,22 @@ marked `async*`, or `sync*` has return type `void`.
312
312
"fire-and-forget" operation, that is, it is not even useful for the caller
313
313
to synchronize with the completion of that task.*
314
314
315
+ It is a static warning (Dart 2: a compile-time error) for a for-in
316
+ statement to have an iterator expression of type ` T ` such that
317
+ ` Iterator<void> ` is the most specific instantiation of ` Iterator ` that is a
318
+ superinterface of ` T ` , unless the iteration variable has type void.
319
+
320
+ It is a static warning (Dart 2: a compile-time error) for an asynchronous
321
+ for-in statement to have a stream expression of type ` T ` such that
322
+ ` Stream<void> ` is the most specific instantiation of ` Stream ` that is a
323
+ superinterface of ` T ` , unless the iteration variable has type void.
324
+
325
+ * Hence, ` for (Object x in <void>[]) {} ` and
326
+ ` await for (int x in new Stream<void>.empty()) {} ` are errors, whereas
327
+ ` for (void x in <void>[]) {...} ` and ` for (var x in <void>[]) {...} ` are OK. The
328
+ usage of ` x ` in the loop body is constrained, though, because it has type
329
+ void.*
330
+
315
331
During bounds checking, it is possible that a bound of a formal type
316
332
parameter of a generic class or function is statically known to be the type
317
333
void. In this case, the bound is considered to be the built-in class
You can’t perform that action at this time.
0 commit comments