Skip to content

Commit a69420c

Browse files
authored
Define NNBD_TOP_MERGE on record types (#3406)
Define NNBD_TOP_MERGE on record types
1 parent 7206f91 commit a69420c

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

accepted/3.0/records/feature-specification.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Author: Bob Nystrom
44

55
Status: Accepted
66

7-
Version 1.20 (see [CHANGELOG](#CHANGELOG) at end)
7+
Version 1.21 (see [CHANGELOG](#CHANGELOG) at end)
88

99
## Motivation
1010

@@ -462,6 +462,27 @@ var c = cond ? a : b; // c has type `Record`.
462462

463463
The greatest lower bound of records with different shapes is `Never`.
464464

465+
### Combined member signatures
466+
467+
In order to determine how a combined member signature is computed when one
468+
or more types in the signature is a record type, we need to extend the
469+
definition of the type function `NNBD_TOP_MERGE` when it is applied to a
470+
record type:
471+
472+
`NNBD_TOP_MERGE` is only defined when it is applied to two types with the
473+
same structure, in particular: It is only defined on two record types when
474+
they have the same shape.
475+
476+
When it is applied to two record types with the same shape, the result
477+
is a record type with the same shape again, where each field type is
478+
obtained by applying `NNBD_TOP_MERGE` recursively.
479+
480+
*For example:*
481+
482+
```
483+
NNBD_TOP_MERGE((int, {dynamic x}), (int, {void x})) == (int, {Object? x})
484+
```
485+
465486
### Type inference
466487

467488
Every record literal has a static type, which is associated with it via
@@ -829,6 +850,10 @@ library is sufficient to enforce this.*
829850

830851
## CHANGELOG
831852

853+
### 1.21
854+
855+
- Specify handling of record types with `NNBD_TOP_MERGE`.
856+
832857
### 1.20
833858

834859
- Start positional record field getters at `$1`, not `$0` (#2638).

0 commit comments

Comments
 (0)