@@ -2491,7 +2491,7 @@ \subsection{Type of a Function}
2491
2491
different type parameters, F-bounds, and the types of formal parameters.
2492
2492
However, we do not wish to distinguish between two function types if they have
2493
2493
the same structure and only differ in the choice of names.
2494
- This treatment of names is also known as alpha- equivalence.%
2494
+ This treatment of names is also known as alpha equivalence.%
2495
2495
}
2496
2496
2497
2497
\LMHash{}%
@@ -4971,7 +4971,6 @@ \subsection{Superinterfaces}
4971
4971
is not a class building type
4972
4972
(\ref{classBuildingTypes}).
4973
4973
It is a \Error{compile-time error} if two elements in said type list
4974
- %% TODO(eernst): Refer to nnbd notion of 'same type'.
4975
4974
specifies the same type.
4976
4975
It is a \Error{compile-time error} if the superclass of a class $C$ is
4977
4976
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
@@ -23120,35 +23119,45 @@ \subsection{Type Type}
23120
23119
\LMHash{}%
23121
23120
The Dart runtime supports a very limited kind of introspective reflection
23122
23121
for all programs
23123
- (\commentary{%
23124
- that is, without including any reflection support mechanisms,
23125
- e.g., importing \code{dart:mirrors},
23126
- or using reflection related code generation%
23127
- }).
23122
+ (\commentary{that is, without including any reflection support mechanisms}).
23128
23123
In particular, evaluation of a type literal as an expression yields
23129
23124
an object whose run-time type is a subtype of the built-in type \code{Type}.
23130
- System libraries may deliver such objects as well
23131
- (\commentary{e.g., the method \code{runtimeType} on \code{Object}}).
23125
+ System libraries may deliver such objects as well.
23126
+ In particular, the getter \code{runtimeType} on \code{Object}
23127
+ returns a reified type for the run-time type of the receiver.
23128
+
23129
+ \LMHash{}%
23132
23130
If an object $o$ is obtained in this manner
23133
- as a reification of the Dart type $T$,
23131
+ as a reification of the type $T$,
23134
23132
we say that $o$ is a \Index{reified type},
23135
23133
and we say that $o$ \IndexCustom{reifies}{type!reifies} $T$.
23136
23134
23137
- %% TODO(eernst): Define "same type" in one location in this spec, use it here.
23138
23135
\LMHash{}%
23139
- A reified type identifies the underlying Dart type in the sense that
23136
+ We define what it means for two types to be the same as follows:
23137
+ Let $T_1$ and $T_2$ be types.
23138
+ Let $U_j$ be the transitive alias expansion
23139
+ (\ref{typedef}) of $T_j$, for $j \in 1 .. 2$.
23140
+ We say that $T_1$ and $T_2$ are the \Index{same type}
23141
+ if{}f \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
23142
+ (\ref{typeNormalization})
23143
+ are syntactically equal,
23144
+ up to equivalence of bound variables,
23145
+ and up to replacement of identifiers or qualified identifiers
23146
+ resolving to the same type declaration
23147
+ (\commentary{%
23148
+ e.g., \code{C} and \code{prefix.C} could resolve to
23149
+ the same class declaration%
23150
+ }).
23151
+
23152
+ \LMHash{}%
23153
+ A reified type identifies the underlying type in the sense that
23140
23154
it supports equality tests with other reified types as follows.
23141
- Let $o_1$ and $o_2$ be reified types that reify $S_1 $ respectively $S_2 $,
23155
+ Let $o_1$ and $o_2$ be reified types that reify $T_1 $ respectively $T_2 $,
23142
23156
and let $o_3$ be an object which is not a reified type.
23143
- Let $U_j$ be the transitive alias expansion of $S_j$, for $j \in 1 .. 3$,
23144
- and let $v_j$ be a fresh variable whose value is $o_j$, for $j \in 1 .. 3$.
23145
- It is then guaranteed that \code{$v_1$ == $v_2$} if{}f
23146
- \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
23147
- are syntactically equal,
23148
- up to equivalence of bound variables
23149
- and up to designations of the same type using different syntax
23150
- (\commentary{e.g., \code{C} and \code{prefix.C} may denote the same type}).
23151
- Conversely, \code{$v_1$ == $v_3$} will yield false.
23157
+ Let $v_j$ be a fresh variable bound to $o_j$, for $j \in 1 .. 3$.
23158
+ It is then guaranteed that \code{$v_1$ == $v_2$} evaluates to \TRUE{}
23159
+ if{}f $T_1$ and $T_2$ are the same type as defined above.
23160
+ Conversely, \code{$v_1$ == $v_3$} evaluates to \FALSE.
23152
23161
23153
23162
\commentary{%
23154
23163
Note that we do not equate primitive top types.
@@ -23184,10 +23193,10 @@ \subsection{Type Type}
23184
23193
Let $e_1$ and $e_2$ be constant expressions
23185
23194
(\ref{constants})
23186
23195
evaluating to $o_1$ respectively $o_2$,
23187
- which are reified types reifying the Dart types $S_1 $ respecively $S_2 $.
23196
+ which are reified types reifying the types $T_1 $ respecively $T_2 $.
23188
23197
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
23189
23198
We then have \code{identical($v_1$, $v_2$)} if{}f
23190
- \code{$S_1 $\,\,==\,\,$S_2 $}.
23199
+ \code{$T_1 $\,\,==\,\,$T_2 $}.
23191
23200
23192
23201
\commentary{%
23193
23202
In other words, constant reified types are canonicalized.
@@ -23209,6 +23218,7 @@ \subsection{Type Type}
23209
23218
It is also impossible to deconstruct a reified type.
23210
23219
E.g., we cannot obtain the reified type for \code{$T$}
23211
23220
by performing operations on a given reified type for \code{List<$T$>}.
23221
+
23212
23222
This design was chosen in order to ensure that Dart programs
23213
23223
do not incur the substantial implications in terms of
23214
23224
program size and run-time performance
0 commit comments