Skip to content

Commit 0146316

Browse files
committed
Type Type fixes
1 parent 6fde36a commit 0146316

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
@@ -2491,7 +2491,7 @@ \subsection{Type of a Function}
24912491
different type parameters, F-bounds, and the types of formal parameters.
24922492
However, we do not wish to distinguish between two function types if they have
24932493
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.%
24952495
}
24962496

24972497
\LMHash{}%
@@ -4971,7 +4971,6 @@ \subsection{Superinterfaces}
49714971
is not a class building type
49724972
(\ref{classBuildingTypes}).
49734973
It is a \Error{compile-time error} if two elements in said type list
4974-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
49754974
specifies the same type.
49764975
It is a \Error{compile-time error} if the superclass of a class $C$ is
49774976
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
@@ -23120,35 +23119,45 @@ \subsection{Type Type}
2312023119
\LMHash{}%
2312123120
The Dart runtime supports a very limited kind of introspective reflection
2312223121
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}).
2312823123
In particular, evaluation of a type literal as an expression yields
2312923124
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{}%
2313223130
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$,
2313423132
we say that $o$ is a \Index{reified type},
2313523133
and we say that $o$ \IndexCustom{reifies}{type!reifies} $T$.
2313623134

23137-
%% TODO(eernst): Define "same type" in one location in this spec, use it here.
2313823135
\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
2314023154
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$,
2314223156
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.
2315223161

2315323162
\commentary{%
2315423163
Note that we do not equate primitive top types.
@@ -23184,10 +23193,10 @@ \subsection{Type Type}
2318423193
Let $e_1$ and $e_2$ be constant expressions
2318523194
(\ref{constants})
2318623195
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$.
2318823197
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
2318923198
We then have \code{identical($v_1$, $v_2$)} if{}f
23190-
\code{$S_1$\,\,==\,\,$S_2$}.
23199+
\code{$T_1$\,\,==\,\,$T_2$}.
2319123200

2319223201
\commentary{%
2319323202
In other words, constant reified types are canonicalized.
@@ -23209,6 +23218,7 @@ \subsection{Type Type}
2320923218
It is also impossible to deconstruct a reified type.
2321023219
E.g., we cannot obtain the reified type for \code{$T$}
2321123220
by performing operations on a given reified type for \code{List<$T$>}.
23221+
2321223222
This design was chosen in order to ensure that Dart programs
2321323223
do not incur the substantial implications in terms of
2321423224
program size and run-time performance

0 commit comments

Comments
 (0)