@@ -2483,7 +2483,7 @@ \subsection{Type of a Function}
2483
2483
different type parameters, F-bounds, and the types of formal parameters.
2484
2484
However, we do not wish to distinguish between two function types if they have
2485
2485
the same structure and only differ in the choice of names.
2486
- This treatment of names is also known as alpha- equivalence.%
2486
+ This treatment of names is also known as alpha equivalence.%
2487
2487
}
2488
2488
2489
2489
\LMHash{}%
@@ -4963,7 +4963,6 @@ \subsection{Superinterfaces}
4963
4963
is not a class building type
4964
4964
(\ref{classBuildingTypes}).
4965
4965
It is a \Error{compile-time error} if two elements in said type list
4966
- %% TODO(eernst): Refer to nnbd notion of 'same type'.
4967
4966
specifies the same type.
4968
4967
It is a \Error{compile-time error} if the superclass of a class $C$ is
4969
4968
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
@@ -22982,35 +22981,45 @@ \subsection{Type Type}
22982
22981
\LMHash{}%
22983
22982
The Dart runtime supports a very limited kind of introspective reflection
22984
22983
for all programs
22985
- (\commentary{%
22986
- that is, without including any reflection support mechanisms,
22987
- e.g., importing \code{dart:mirrors},
22988
- or using reflection related code generation%
22989
- }).
22984
+ (\commentary{that is, without including any reflection support mechanisms}).
22990
22985
In particular, evaluation of a type literal as an expression yields
22991
22986
an object whose run-time type is a subtype of the built-in type \code{Type}.
22992
- System libraries may deliver such objects as well
22993
- (\commentary{e.g., the method \code{runtimeType} on \code{Object}}).
22987
+ System libraries may deliver such objects as well.
22988
+ In particular, the getter \code{runtimeType} on \code{Object}
22989
+ returns a reified type for the run-time type of the receiver.
22990
+
22991
+ \LMHash{}%
22994
22992
If an object $o$ is obtained in this manner
22995
- as a reification of the Dart type $T$,
22993
+ as a reification of the type $T$,
22996
22994
we say that $o$ is a \Index{reified type},
22997
22995
and we say that $o$ \IndexCustom{reifies}{type!reifies} $T$.
22998
22996
22999
- %% TODO(eernst): Define "same type" in one location in this spec, use it here.
23000
22997
\LMHash{}%
23001
- A reified type identifies the underlying Dart type in the sense that
22998
+ We define what it means for two types to be the same as follows:
22999
+ Let $T_1$ and $T_2$ be types.
23000
+ Let $U_j$ be the transitive alias expansion
23001
+ (\ref{typedef}) of $T_j$, for $j \in 1 .. 2$.
23002
+ We say that $T_1$ and $T_2$ are the \Index{same type}
23003
+ if{}f \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
23004
+ (\ref{typeNormalization})
23005
+ are syntactically equal,
23006
+ up to equivalence of bound variables,
23007
+ and up to replacement of identifiers or qualified identifiers
23008
+ resolving to the same type declaration
23009
+ (\commentary{%
23010
+ e.g., \code{C} and \code{prefix.C} could resolve to
23011
+ the same class declaration%
23012
+ }).
23013
+
23014
+ \LMHash{}%
23015
+ A reified type identifies the underlying type in the sense that
23002
23016
it supports equality tests with other reified types as follows.
23003
- Let $o_1$ and $o_2$ be reified types that reify $S_1 $ respectively $S_2 $,
23017
+ Let $o_1$ and $o_2$ be reified types that reify $T_1 $ respectively $T_2 $,
23004
23018
and let $o_3$ be an object which is not a reified type.
23005
- Let $U_j$ be the transitive alias expansion of $S_j$, for $j \in 1 .. 3$,
23006
- and let $v_j$ be a fresh variable whose value is $o_j$, for $j \in 1 .. 3$.
23007
- It is then guaranteed that \code{$v_1$ == $v_2$} if{}f
23008
- \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
23009
- are syntactically equal,
23010
- up to equivalence of bound variables
23011
- and up to designations of the same type using different syntax
23012
- (\commentary{e.g., \code{C} and \code{prefix.C} may denote the same type}).
23013
- Conversely, \code{$v_1$ == $v_3$} will yield false.
23019
+ Let $v_j$ be a fresh variable bound to $o_j$, for $j \in 1 .. 3$.
23020
+ It is then guaranteed that \code{$v_1$ == $v_2$} evaluates to \TRUE{}
23021
+ if{}f $T_1$ and $T_2$ are the same type as defined above.
23022
+ Conversely, \code{$v_1$ == $v_3$} evaluates to \FALSE.
23014
23023
23015
23024
\commentary{%
23016
23025
Note that we do not equate primitive top types.
@@ -23046,10 +23055,10 @@ \subsection{Type Type}
23046
23055
Let $e_1$ and $e_2$ be constant expressions
23047
23056
(\ref{constants})
23048
23057
evaluating to $o_1$ respectively $o_2$,
23049
- which are reified types reifying the Dart types $S_1 $ respecively $S_2 $.
23058
+ which are reified types reifying the types $T_1 $ respecively $T_2 $.
23050
23059
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
23051
23060
We then have \code{identical($v_1$, $v_2$)} if{}f
23052
- \code{$S_1 $\,\,==\,\,$S_2 $}.
23061
+ \code{$T_1 $\,\,==\,\,$T_2 $}.
23053
23062
23054
23063
\commentary{%
23055
23064
In other words, constant reified types are canonicalized.
@@ -23071,6 +23080,7 @@ \subsection{Type Type}
23071
23080
It is also impossible to deconstruct a reified type.
23072
23081
E.g., we cannot obtain the reified type for \code{$T$}
23073
23082
by performing operations on a given reified type for \code{List<$T$>}.
23083
+
23074
23084
This design was chosen in order to ensure that Dart programs
23075
23085
do not incur the substantial implications in terms of
23076
23086
program size and run-time performance
0 commit comments