Skip to content

Commit a843939

Browse files
authored
Merge pull request #730 from dart-lang/equality
Specify runtime type equality and weak checking const canonicalization
2 parents 2311909 + 05b1202 commit a843939

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

accepted/future-releases/nnbd/feature-specification.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,36 @@ These are extended as per separate proposal.
493493

494494
## Runtime semantics
495495

496+
### Runtime type equality operator
497+
498+
Two objects `T1` and `T2` which are instances of `Type` (that is, runtime type
499+
objects) are considered equal if and only if their normal forms **NORM(`T1`)**
500+
and **NORM(`T2`)** are syntactically equal up to equivalence of bound variables
501+
and **ignoring `*` modifiers on types**. So for example, the runtime type
502+
objects corresponding to `List<int>` and `List<int*>` are considered equal.
503+
Note that we do not equate primitive top types. `List<void>` and
504+
`List<dynamic>` are still considered distinct runtime type objects. Note that
505+
we also do not equate `Never` and `Null`, and we do not equate function types
506+
which differ in the placement of `required` on parameter types. Because of
507+
this, the equality described here is not equivalent to syntactic equality on the
508+
`LEGACY_ERASURE` of the types.
509+
510+
511+
### Const evaluation and canonicalization
512+
513+
In weak checking mode, all generic const constructors and generic const literals
514+
are treated as if all type arguments passed to them were legacy types (both at
515+
the top level, and recursively over the structure of the types), regardless of
516+
whether the constructed class is defined in a legacy library or not, and
517+
regardless of whether the constructor invocation or literal occurs in a legacy
518+
library or not. This ensures that const objects continue to canonicalize
519+
consistently across legacy and opted-in libraries.
520+
521+
In strong checking mode, all generic const constructors and generic const
522+
literals are evaluated using the actual type arguments provided, whether legacy
523+
or non-legacy. This ensures that in strong checking mode, the final consistent
524+
semantics are obeyed.
525+
496526
### Null check operator
497527

498528
An expression of the form `e!` evaluates `e` to a value `v`, throws a runtime

0 commit comments

Comments
 (0)