@@ -2663,7 +2663,7 @@ \subsection{Type of a Function}
2663
2663
different type parameters, F-bounds, and the types of formal parameters.
2664
2664
However, we do not wish to distinguish between two function types if they have
2665
2665
the same structure and only differ in the choice of names.
2666
- This treatment of names is also known as alpha- equivalence.%
2666
+ This treatment of names is also known as alpha equivalence.%
2667
2667
}
2668
2668
2669
2669
\LMHash{}%
@@ -5149,7 +5149,6 @@ \subsection{Superinterfaces}
5149
5149
is not a class building type
5150
5150
(\ref{classBuildingTypes}).
5151
5151
It is a \Error{compile-time error} if two elements in said type list
5152
- %% TODO(eernst): Refer to nnbd notion of 'same type'.
5153
5152
specifies the same type.
5154
5153
It is a \Error{compile-time error} if the superclass of a class $C$ is
5155
5154
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
@@ -23358,35 +23357,45 @@ \subsection{Type Type}
23358
23357
\LMHash{}%
23359
23358
The Dart runtime supports a very limited kind of introspective reflection
23360
23359
for all programs
23361
- (\commentary{%
23362
- that is, without including any reflection support mechanisms,
23363
- e.g., importing \code{dart:mirrors},
23364
- or using reflection related code generation%
23365
- }).
23360
+ (\commentary{that is, without including any reflection support mechanisms}).
23366
23361
In particular, evaluation of a type literal as an expression yields
23367
23362
an object whose run-time type is a subtype of the built-in type \code{Type}.
23368
- System libraries may deliver such objects as well
23369
- (\commentary{e.g., the method \code{runtimeType} on \code{Object}}).
23363
+ System libraries may deliver such objects as well.
23364
+ In particular, the getter \code{runtimeType} on \code{Object}
23365
+ returns a reified type for the run-time type of the receiver.
23366
+
23367
+ \LMHash{}%
23370
23368
If an object $o$ is obtained in this manner
23371
- as a reification of the Dart type $T$,
23369
+ as a reification of the type $T$,
23372
23370
we say that $o$ is a \Index{reified type},
23373
23371
and we say that $o$ \IndexCustom{reifies}{type!reifies} $T$.
23374
23372
23375
- %% TODO(eernst): Define "same type" in one location in this spec, use it here.
23376
23373
\LMHash{}%
23377
- A reified type identifies the underlying Dart type in the sense that
23374
+ We define what it means for two types to be the same as follows:
23375
+ Let $T_1$ and $T_2$ be types.
23376
+ Let $U_j$ be the transitive alias expansion
23377
+ (\ref{typedef}) of $T_j$, for $j \in 1 .. 2$.
23378
+ We say that $T_1$ and $T_2$ are the \Index{same type}
23379
+ if{}f \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
23380
+ (\ref{typeNormalization})
23381
+ are syntactically equal,
23382
+ up to equivalence of bound variables,
23383
+ and up to replacement of identifiers or qualified identifiers
23384
+ resolving to the same type declaration
23385
+ (\commentary{%
23386
+ e.g., \code{C} and \code{prefix.C} could resolve to
23387
+ the same class declaration%
23388
+ }).
23389
+
23390
+ \LMHash{}%
23391
+ A reified type identifies the underlying type in the sense that
23378
23392
it supports equality tests with other reified types as follows.
23379
- Let $o_1$ and $o_2$ be reified types that reify $S_1 $ respectively $S_2 $,
23393
+ Let $o_1$ and $o_2$ be reified types that reify $T_1 $ respectively $T_2 $,
23380
23394
and let $o_3$ be an object which is not a reified type.
23381
- Let $U_j$ be the transitive alias expansion of $S_j$, for $j \in 1 .. 3$,
23382
- and let $v_j$ be a fresh variable whose value is $o_j$, for $j \in 1 .. 3$.
23383
- It is then guaranteed that \code{$v_1$ == $v_2$} if{}f
23384
- \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
23385
- are syntactically equal,
23386
- up to equivalence of bound variables
23387
- and up to designations of the same type using different syntax
23388
- (\commentary{e.g., \code{C} and \code{prefix.C} may denote the same type}).
23389
- Conversely, \code{$v_1$ == $v_3$} will yield false.
23395
+ Let $v_j$ be a fresh variable bound to $o_j$, for $j \in 1 .. 3$.
23396
+ It is then guaranteed that \code{$v_1$ == $v_2$} evaluates to \TRUE{}
23397
+ if{}f $T_1$ and $T_2$ are the same type as defined above.
23398
+ Conversely, \code{$v_1$ == $v_3$} evaluates to \FALSE.
23390
23399
23391
23400
\commentary{%
23392
23401
Note that we do not equate primitive top types.
@@ -23422,10 +23431,10 @@ \subsection{Type Type}
23422
23431
Let $e_1$ and $e_2$ be constant expressions
23423
23432
(\ref{constants})
23424
23433
evaluating to $o_1$ respectively $o_2$,
23425
- which are reified types reifying the Dart types $S_1 $ respecively $S_2 $.
23434
+ which are reified types reifying the types $T_1 $ respecively $T_2 $.
23426
23435
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
23427
23436
We then have \code{identical($v_1$, $v_2$)} if{}f
23428
- \code{$S_1 $\,\,==\,\,$S_2 $}.
23437
+ \code{$T_1 $\,\,==\,\,$T_2 $}.
23429
23438
23430
23439
\commentary{%
23431
23440
In other words, constant reified types are canonicalized.
@@ -23447,6 +23456,7 @@ \subsection{Type Type}
23447
23456
It is also impossible to deconstruct a reified type.
23448
23457
E.g., we cannot obtain the reified type for \code{$T$}
23449
23458
by performing operations on a given reified type for \code{List<$T$>}.
23459
+
23450
23460
This design was chosen in order to ensure that Dart programs
23451
23461
do not incur the substantial implications in terms of
23452
23462
program size and run-time performance
0 commit comments