@@ -2468,7 +2468,7 @@ \subsection{Type of a Function}
2468
2468
different type parameters, F-bounds, and the types of formal parameters.
2469
2469
However, we do not wish to distinguish between two function types if they have
2470
2470
the same structure and only differ in the choice of names.
2471
- This treatment of names is also known as alpha- equivalence.%
2471
+ This treatment of names is also known as alpha equivalence.%
2472
2472
}
2473
2473
2474
2474
\LMHash{}%
@@ -4923,7 +4923,6 @@ \subsection{Superinterfaces}
4923
4923
is not a class building type
4924
4924
(\ref{classBuildingTypes}).
4925
4925
It is a \Error{compile-time error} if two elements in said type list
4926
- %% TODO(eernst): Refer to nnbd notion of 'same type'.
4927
4926
specifies the same type.
4928
4927
It is a \Error{compile-time error} if the superclass of a class $C$ is
4929
4928
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
@@ -22853,35 +22852,45 @@ \subsection{Type Type}
22853
22852
\LMHash{}%
22854
22853
The Dart runtime supports a very limited kind of introspective reflection
22855
22854
for all programs
22856
- (\commentary{%
22857
- that is, without including any reflection support mechanisms,
22858
- e.g., importing \code{dart:mirrors},
22859
- or using reflection related code generation%
22860
- }).
22855
+ (\commentary{that is, without including any reflection support mechanisms}).
22861
22856
In particular, evaluation of a type literal as an expression yields
22862
22857
an object whose run-time type is a subtype of the built-in type \code{Type}.
22863
- System libraries may deliver such objects as well
22864
- (\commentary{e.g., the method \code{runtimeType} on \code{Object}}).
22858
+ System libraries may deliver such objects as well.
22859
+ In particular, the getter \code{runtimeType} on \code{Object}
22860
+ returns a reified type for the run-time type of the receiver.
22861
+
22862
+ \LMHash{}%
22865
22863
If an object $o$ is obtained in this manner
22866
- as a reification of the Dart type $T$,
22864
+ as a reification of the type $T$,
22867
22865
we say that $o$ is a \Index{reified type},
22868
22866
and we say that $o$ \IndexCustom{reifies}{type!reifies} $T$.
22869
22867
22870
- %% TODO(eernst): Define "same type" in one location in this spec, use it here.
22871
22868
\LMHash{}%
22872
- A reified type identifies the underlying Dart type in the sense that
22869
+ We define what it means for two types to be the same as follows:
22870
+ Let $T_1$ and $T_2$ be types.
22871
+ Let $U_j$ be the transitive alias expansion
22872
+ (\ref{typedef}) of $T_j$, for $j \in 1 .. 2$.
22873
+ We say that $T_1$ and $T_2$ are the \Index{same type}
22874
+ if{}f \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
22875
+ (\ref{typeNormalization})
22876
+ are syntactically equal,
22877
+ up to equivalence of bound variables,
22878
+ and up to replacement of identifiers or qualified identifiers
22879
+ resolving to the same type declaration
22880
+ (\commentary{%
22881
+ e.g., \code{C} and \code{prefix.C} could resolve to
22882
+ the same class declaration%
22883
+ }).
22884
+
22885
+ \LMHash{}%
22886
+ A reified type identifies the underlying type in the sense that
22873
22887
it supports equality tests with other reified types as follows.
22874
- Let $o_1$ and $o_2$ be reified types that reify $S_1 $ respectively $S_2 $,
22888
+ Let $o_1$ and $o_2$ be reified types that reify $T_1 $ respectively $T_2 $,
22875
22889
and let $o_3$ be an object which is not a reified type.
22876
- Let $U_j$ be the transitive alias expansion of $S_j$, for $j \in 1 .. 3$,
22877
- and let $v_j$ be a fresh variable whose value is $o_j$, for $j \in 1 .. 3$.
22878
- It is then guaranteed that \code{$v_1$ == $v_2$} if{}f
22879
- \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
22880
- are syntactically equal,
22881
- up to equivalence of bound variables
22882
- and up to designations of the same type using different syntax
22883
- (\commentary{e.g., \code{C} and \code{prefix.C} may denote the same type}).
22884
- Conversely, \code{$v_1$ == $v_3$} will yield false.
22890
+ Let $v_j$ be a fresh variable bound to $o_j$, for $j \in 1 .. 3$.
22891
+ It is then guaranteed that \code{$v_1$ == $v_2$} evaluates to \TRUE{}
22892
+ if{}f $T_1$ and $T_2$ are the same type as defined above.
22893
+ Conversely, \code{$v_1$ == $v_3$} evaluates to \FALSE.
22885
22894
22886
22895
\commentary{%
22887
22896
Note that we do not equate primitive top types.
@@ -22917,10 +22926,10 @@ \subsection{Type Type}
22917
22926
Let $e_1$ and $e_2$ be constant expressions
22918
22927
(\ref{constants})
22919
22928
evaluating to $o_1$ respectively $o_2$,
22920
- which are reified types reifying the Dart types $S_1 $ respecively $S_2 $.
22929
+ which are reified types reifying the types $T_1 $ respecively $T_2 $.
22921
22930
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
22922
22931
We then have \code{identical($v_1$, $v_2$)} if{}f
22923
- \code{$S_1 $\,\,==\,\,$S_2 $}.
22932
+ \code{$T_1 $\,\,==\,\,$T_2 $}.
22924
22933
22925
22934
\commentary{%
22926
22935
In other words, constant reified types are canonicalized.
@@ -22942,6 +22951,7 @@ \subsection{Type Type}
22942
22951
It is also impossible to deconstruct a reified type.
22943
22952
E.g., we cannot obtain the reified type for \code{$T$}
22944
22953
by performing operations on a given reified type for \code{List<$T$>}.
22954
+
22945
22955
This design was chosen in order to ensure that Dart programs
22946
22956
do not incur the substantial implications in terms of
22947
22957
program size and run-time performance
0 commit comments