Skip to content

Commit f320a94

Browse files
committed
Type Type fixes
1 parent a3eeae1 commit f320a94

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

specification/dartLangSpec.tex

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2468,7 +2468,7 @@ \subsection{Type of a Function}
24682468
different type parameters, F-bounds, and the types of formal parameters.
24692469
However, we do not wish to distinguish between two function types if they have
24702470
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.%
24722472
}
24732473

24742474
\LMHash{}%
@@ -4923,7 +4923,6 @@ \subsection{Superinterfaces}
49234923
is not a class building type
49244924
(\ref{classBuildingTypes}).
49254925
It is a \Error{compile-time error} if two elements in said type list
4926-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
49274926
specifies the same type.
49284927
It is a \Error{compile-time error} if the superclass of a class $C$ is
49294928
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
@@ -22853,35 +22852,45 @@ \subsection{Type Type}
2285322852
\LMHash{}%
2285422853
The Dart runtime supports a very limited kind of introspective reflection
2285522854
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}).
2286122856
In particular, evaluation of a type literal as an expression yields
2286222857
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{}%
2286522863
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$,
2286722865
we say that $o$ is a \Index{reified type},
2286822866
and we say that $o$ \IndexCustom{reifies}{type!reifies} $T$.
2286922867

22870-
%% TODO(eernst): Define "same type" in one location in this spec, use it here.
2287122868
\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
2287322887
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$,
2287522889
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.
2288522894

2288622895
\commentary{%
2288722896
Note that we do not equate primitive top types.
@@ -22917,10 +22926,10 @@ \subsection{Type Type}
2291722926
Let $e_1$ and $e_2$ be constant expressions
2291822927
(\ref{constants})
2291922928
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$.
2292122930
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
2292222931
We then have \code{identical($v_1$, $v_2$)} if{}f
22923-
\code{$S_1$\,\,==\,\,$S_2$}.
22932+
\code{$T_1$\,\,==\,\,$T_2$}.
2292422933

2292522934
\commentary{%
2292622935
In other words, constant reified types are canonicalized.
@@ -22942,6 +22951,7 @@ \subsection{Type Type}
2294222951
It is also impossible to deconstruct a reified type.
2294322952
E.g., we cannot obtain the reified type for \code{$T$}
2294422953
by performing operations on a given reified type for \code{List<$T$>}.
22954+
2294522955
This design was chosen in order to ensure that Dart programs
2294622956
do not incur the substantial implications in terms of
2294722957
program size and run-time performance

0 commit comments

Comments
 (0)