Skip to content

Commit e349009

Browse files
committed
Addressed comments.
1 parent a23e438 commit e349009

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

resources/type-system/inference.md

+21-17
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,15 @@ and the values emitted by generator functions._
352352

353353
Let `K` be the value context schema for the function body as computed above
354354
from the imposed return type schema.
355-
_When we refer to the _inferred type_ of an expression with a typing context,
356-
it is the type inferred using the local type inference algorithm
357-
described below._
355+
_When we refer to the inferred type of an expression with a typing context,
356+
it is the static type of the expression inferred using the local type inference
357+
algorithm described below._
358358

359359
The actual value type of a function literal with an expression body, `=> e`,
360360
_(which cannot be a generator function)_ is computed as follows:
361361
- If the enclosing function is marked `async`,
362-
let `T` be the inferred type of the returned expession with `FutureOr<K>`
363-
as typing context.
362+
then let `T` be the inferred type of the returned expession with
363+
`FutureOr<K>` as typing context.
364364
The actual value type is **flatten**(`T`).
365365
- If the enclosing function is not marked `async`, let `T` be the inferred
366366
type of the returned expression with typing context `K`.
@@ -380,17 +380,16 @@ to find a value type `V` for that statement.
380380

381381
- If the enclosing function is a non-`async` non-generator function,
382382
the relevant statements are `return;` or `return e;` statements.
383-
- For a `return;` statement, let `V` be `Null`.
384-
- For a `return e;` statement, let `V` be the inferred type of `e` with
385-
`K` as context type scheme, using the local type inference algorithm
386-
described below.
383+
* For a `return;` statement, let `V` be `Null`.
384+
* For a `return e;` statement, let `V` be the inferred type of `e` with
385+
`K` as context type scheme.
387386

388387
- If the enclosing function is marked `async`, the relevant statements
389-
are `return;` and `return e;` statements.
388+
are `return;` and `return e;` statements.
390389
* For a `return;` statement, let `V` be `Null`.
391-
* For a `return e;` statement, let `S` be the inferred type of `e`
392-
with typing context `_` if `K` is `_`,
393-
and with typing context `FutureOr<K>` if `K` is not `_`,
390+
* For a `return e;` statement,
391+
then let `S` be the inferred type of `e` with typing context
392+
`FutureOr<K>`.
394393
Let `V` be **flatten**(`S`).
395394

396395
- If the enclosing function is marked `sync*`, the relevant statements
@@ -417,7 +416,7 @@ to find a value type `V` for that statement.
417416
`Stream<Object?>`, so either `S` implements `Stream`,
418417
or it is one of `dynamic` or `Never`._
419418

420-
After processing each relevant statement, update `T` to be **UP**(`T`, `V`).
419+
After processing each relevant statement, update `T` to be **UP**(`V`, `T`).
421420

422421
The **actual value type** of the function literal is the value of `T` after
423422
all relevant `return` and `yield` statements in the block body have been
@@ -426,12 +425,17 @@ processed.
426425
Let `T` be the **actual value type** of a function literal as computed above.
427426
Let `R` be the greatest closure of the typing context `K` as computed above.
428427

428+
_Then compute the actual value/element type, `S`, to use in the inferred return
429+
type of the function literal, based on the _actual value type_, but bounded
430+
by the _typing context_, if any._
431+
429432
With null safety, if `R` is `void`, let `S` be `void`
430433
_(without null-safety: no special treatment is applicable to `void`)_.
431434

432-
Otherwise (_without null safety or if `R` is not `void`_),
433-
if `T <: R` then let `S` be `T`, else let `S` be `R`. The
434-
inferred return type of the function literal is then defined as follows:
435+
Otherwise (_if `R` is not `void`, or without null safety_),
436+
if `T <: R` then let `S` be `T`, else let `S` be `R`.
437+
438+
The inferred return type of the function literal is then defined as follows:
435439

436440
- If the function literal is marked `async` then the inferred return type is
437441
`Future<S>`.

0 commit comments

Comments
 (0)