Skip to content

Commit 94cbd4b

Browse files
committed
Type Type fixes
1 parent 0aa58cb commit 94cbd4b

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
@@ -2483,7 +2483,7 @@ \subsection{Type of a Function}
24832483
different type parameters, F-bounds, and the types of formal parameters.
24842484
However, we do not wish to distinguish between two function types if they have
24852485
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.%
24872487
}
24882488

24892489
\LMHash{}%
@@ -4963,7 +4963,6 @@ \subsection{Superinterfaces}
49634963
is not a class building type
49644964
(\ref{classBuildingTypes}).
49654965
It is a \Error{compile-time error} if two elements in said type list
4966-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
49674966
specifies the same type.
49684967
It is a \Error{compile-time error} if the superclass of a class $C$ is
49694968
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
@@ -22982,35 +22981,45 @@ \subsection{Type Type}
2298222981
\LMHash{}%
2298322982
The Dart runtime supports a very limited kind of introspective reflection
2298422983
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}).
2299022985
In particular, evaluation of a type literal as an expression yields
2299122986
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{}%
2299422992
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$,
2299622994
we say that $o$ is a \Index{reified type},
2299722995
and we say that $o$ \IndexCustom{reifies}{type!reifies} $T$.
2299822996

22999-
%% TODO(eernst): Define "same type" in one location in this spec, use it here.
2300022997
\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
2300223016
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$,
2300423018
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.
2301423023

2301523024
\commentary{%
2301623025
Note that we do not equate primitive top types.
@@ -23046,10 +23055,10 @@ \subsection{Type Type}
2304623055
Let $e_1$ and $e_2$ be constant expressions
2304723056
(\ref{constants})
2304823057
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$.
2305023059
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
2305123060
We then have \code{identical($v_1$, $v_2$)} if{}f
23052-
\code{$S_1$\,\,==\,\,$S_2$}.
23061+
\code{$T_1$\,\,==\,\,$T_2$}.
2305323062

2305423063
\commentary{%
2305523064
In other words, constant reified types are canonicalized.
@@ -23071,6 +23080,7 @@ \subsection{Type Type}
2307123080
It is also impossible to deconstruct a reified type.
2307223081
E.g., we cannot obtain the reified type for \code{$T$}
2307323082
by performing operations on a given reified type for \code{List<$T$>}.
23083+
2307423084
This design was chosen in order to ensure that Dart programs
2307523085
do not incur the substantial implications in terms of
2307623086
program size and run-time performance

0 commit comments

Comments
 (0)