Skip to content

Commit e6fb219

Browse files
committed
Type Type fixes
1 parent 895184d commit e6fb219

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
@@ -2663,7 +2663,7 @@ \subsection{Type of a Function}
26632663
different type parameters, F-bounds, and the types of formal parameters.
26642664
However, we do not wish to distinguish between two function types if they have
26652665
the same structure and only differ in the choice of names.
2666-
This treatment of names is also known as alpha-equivalence.%
2666+
This treatment of names is also known as alpha equivalence.%
26672667
}
26682668

26692669
\LMHash{}%
@@ -5149,7 +5149,6 @@ \subsection{Superinterfaces}
51495149
is not a class building type
51505150
(\ref{classBuildingTypes}).
51515151
It is a \Error{compile-time error} if two elements in said type list
5152-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
51535152
specifies the same type.
51545153
It is a \Error{compile-time error} if the superclass of a class $C$ is
51555154
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
@@ -23358,35 +23357,45 @@ \subsection{Type Type}
2335823357
\LMHash{}%
2335923358
The Dart runtime supports a very limited kind of introspective reflection
2336023359
for all programs
23361-
(\commentary{%
23362-
that is, without including any reflection support mechanisms,
23363-
e.g., importing \code{dart:mirrors},
23364-
or using reflection related code generation%
23365-
}).
23360+
(\commentary{that is, without including any reflection support mechanisms}).
2336623361
In particular, evaluation of a type literal as an expression yields
2336723362
an object whose run-time type is a subtype of the built-in type \code{Type}.
23368-
System libraries may deliver such objects as well
23369-
(\commentary{e.g., the method \code{runtimeType} on \code{Object}}).
23363+
System libraries may deliver such objects as well.
23364+
In particular, the getter \code{runtimeType} on \code{Object}
23365+
returns a reified type for the run-time type of the receiver.
23366+
23367+
\LMHash{}%
2337023368
If an object $o$ is obtained in this manner
23371-
as a reification of the Dart type $T$,
23369+
as a reification of the type $T$,
2337223370
we say that $o$ is a \Index{reified type},
2337323371
and we say that $o$ \IndexCustom{reifies}{type!reifies} $T$.
2337423372

23375-
%% TODO(eernst): Define "same type" in one location in this spec, use it here.
2337623373
\LMHash{}%
23377-
A reified type identifies the underlying Dart type in the sense that
23374+
We define what it means for two types to be the same as follows:
23375+
Let $T_1$ and $T_2$ be types.
23376+
Let $U_j$ be the transitive alias expansion
23377+
(\ref{typedef}) of $T_j$, for $j \in 1 .. 2$.
23378+
We say that $T_1$ and $T_2$ are the \Index{same type}
23379+
if{}f \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
23380+
(\ref{typeNormalization})
23381+
are syntactically equal,
23382+
up to equivalence of bound variables,
23383+
and up to replacement of identifiers or qualified identifiers
23384+
resolving to the same type declaration
23385+
(\commentary{%
23386+
e.g., \code{C} and \code{prefix.C} could resolve to
23387+
the same class declaration%
23388+
}).
23389+
23390+
\LMHash{}%
23391+
A reified type identifies the underlying type in the sense that
2337823392
it supports equality tests with other reified types as follows.
23379-
Let $o_1$ and $o_2$ be reified types that reify $S_1$ respectively $S_2$,
23393+
Let $o_1$ and $o_2$ be reified types that reify $T_1$ respectively $T_2$,
2338023394
and let $o_3$ be an object which is not a reified type.
23381-
Let $U_j$ be the transitive alias expansion of $S_j$, for $j \in 1 .. 3$,
23382-
and let $v_j$ be a fresh variable whose value is $o_j$, for $j \in 1 .. 3$.
23383-
It is then guaranteed that \code{$v_1$ == $v_2$} if{}f
23384-
\NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
23385-
are syntactically equal,
23386-
up to equivalence of bound variables
23387-
and up to designations of the same type using different syntax
23388-
(\commentary{e.g., \code{C} and \code{prefix.C} may denote the same type}).
23389-
Conversely, \code{$v_1$ == $v_3$} will yield false.
23395+
Let $v_j$ be a fresh variable bound to $o_j$, for $j \in 1 .. 3$.
23396+
It is then guaranteed that \code{$v_1$ == $v_2$} evaluates to \TRUE{}
23397+
if{}f $T_1$ and $T_2$ are the same type as defined above.
23398+
Conversely, \code{$v_1$ == $v_3$} evaluates to \FALSE.
2339023399

2339123400
\commentary{%
2339223401
Note that we do not equate primitive top types.
@@ -23422,10 +23431,10 @@ \subsection{Type Type}
2342223431
Let $e_1$ and $e_2$ be constant expressions
2342323432
(\ref{constants})
2342423433
evaluating to $o_1$ respectively $o_2$,
23425-
which are reified types reifying the Dart types $S_1$ respecively $S_2$.
23434+
which are reified types reifying the types $T_1$ respecively $T_2$.
2342623435
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
2342723436
We then have \code{identical($v_1$, $v_2$)} if{}f
23428-
\code{$S_1$\,\,==\,\,$S_2$}.
23437+
\code{$T_1$\,\,==\,\,$T_2$}.
2342923438

2343023439
\commentary{%
2343123440
In other words, constant reified types are canonicalized.
@@ -23447,6 +23456,7 @@ \subsection{Type Type}
2344723456
It is also impossible to deconstruct a reified type.
2344823457
E.g., we cannot obtain the reified type for \code{$T$}
2344923458
by performing operations on a given reified type for \code{List<$T$>}.
23459+
2345023460
This design was chosen in order to ensure that Dart programs
2345123461
do not incur the substantial implications in terms of
2345223462
program size and run-time performance

0 commit comments

Comments
 (0)