You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update on top of #941: Some review responses got lost, and flatten(S) must be changed in some locations (#948)
Correct `flatten{S}` to `T_v` in several locations. Update commentary to match changes to return rules. Perform smaller corrections based on review of #941.
Copy file name to clipboardExpand all lines: accepted/future-releases/nnbd/feature-specification.md
+31-22Lines changed: 31 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Status: Draft
11
11
static rules for return statements, and dynamic semantics of return in
12
12
asynchronous non-generators.
13
13
- Add rule that the use of expressions of type `void*` is restricted in
14
-
the same way as expressions of type `void`.
14
+
the same way as the use of expressions of type `void`.
15
15
16
16
2020.04.30
17
17
- Specify static analysis of `e1 == e2`.
@@ -292,7 +292,8 @@ The function **futureValueType** is defined as follows:
292
292
293
293
_Note that it is a compile-time error unless the return type of an asynchronous
294
294
non-generator function is a supertype of `Future<Never>`, which means that
295
-
the last case will only be applied when `S` is a non-`void` top type._
295
+
the last case will only be applied when `S` is `Object` or a non-`void` top
296
+
type._
296
297
297
298
### Return statements
298
299
@@ -306,46 +307,54 @@ about synchronous non-generator functions, the text is changed as follows:
306
307
```
307
308
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
308
309
$T$ is neither \VOID{} nor \DYNAMIC,
309
-
and $S$ is \VOID{} or \code{\VOID*}.
310
+
and $S$ is \VOID.
310
311
```
311
312
312
313
_Comparing to Dart before null-safety, this means that it is no longer allowed
313
-
to "return void to null" in a regular function._
314
+
to return a void expression in a regular function if the return type is
315
+
`Null`._
314
316
315
-
At [this location](https://github.com/dart-lang/language/blob/65b8267be0ebb9b3f0849e2061e6132021a4827d/specification/dartLangSpec.tex#L15525)
317
+
At [this location](https://github.com/dart-lang/language/blob/65b8267be0ebb9b3f0849e2061e6132021a4827d/specification/dartLangSpec.tex#L15507)
316
318
about an asynchronous non-generator function with future value type `$T_v$`,
317
319
the text is changed as follows:
318
320
319
321
```
322
+
It is a compile-time error if $s$ is \code{\RETURN{};},
323
+
unless $T_v$
324
+
is \VOID, \DYNAMIC, or \code{Null}.
325
+
%
326
+
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
327
+
$T_v$ is \VOID,
328
+
and \flatten{S} is neither \VOID, \DYNAMIC, \code{Null}.
329
+
%
320
330
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
321
331
$T_v$ is neither \VOID{} nor \DYNAMIC,
322
-
and \flatten{S} is \VOID{} or \code{\VOID*}.
323
-
```
324
-
325
-
_Comparing to Dart before null-safety, this means that it is no longer allowed
326
-
to "return void to null" in an `async` function, nor to "return a void future
327
-
to null"._
328
-
329
-
The next sentence is changed as follows:
330
-
331
-
```
332
+
and \flatten{S} is \VOID.
333
+
%
332
334
It is a compile-time error if $s$ is \code{\RETURN{} $e$;},
333
335
\flatten{S} is not \VOID,
334
336
$S$ is not assignable to $T_v$,
335
337
and flatten{S} is not a subtype of $T_v$.
336
338
```
337
339
338
-
_Comparing to Dart before null-safety, this means that it is now allowed
339
-
to return a future when the future value type is a suitable future; for
340
-
instance, we can have `return Future<int>.value(42)` in an `async` function
341
-
with declared return type `Future<Future<int>>`. Conversely, it is no longer
342
-
allowed to return a `Future<dynamic>` or `FutureOr<dynamic>` when the future
343
-
value type is `Future<U>` for some `U` which is not a top type._
340
+
_Comparing to Dart before null-safety, this means that it is no longer allowed
341
+
to return an expression whose flattened static type is `void` in an `async`
342
+
function with future value type `Null`; nor is it allowed, in an `async`
343
+
function with future value type `void`, to return an expression whose flattened
344
+
static type is not `void`, `void*`, `dynamic`, or `Null`. Conversely, it is
345
+
allowed to return a future when the future value type is a suitable future;
346
+
for instance, we can have `return Future<int>.value(42)` in an `async` function
347
+
with declared return type `Future<Future<int>>`. Finally, let `S` be
348
+
`Future<dynamic>` or `FutureOr<dynamic>`; it is then no longer allowed to
349
+
return an expression with static type `S`, unless the future value type is a
350
+
supertype of `S`. This differs from Dart before null-safety in that it was
351
+
allowed to return an expression of these types with a declared return type
0 commit comments