Skip to content

Commit e972003

Browse files
committed
More typeType fixes
1 parent f320a94 commit e972003

File tree

1 file changed

+52
-45
lines changed

1 file changed

+52
-45
lines changed

specification/dartLangSpec.tex

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4923,9 +4923,11 @@ \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-
specifies the same type.
4927-
It is a \Error{compile-time error} if the superclass of a class $C$ is
4928-
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
4926+
denotes the same type
4927+
(\ref{typeType}).
4928+
It is a \Error{compile-time error} if the superclass of a class $C$ denotes
4929+
the same type as one of the elements of
4930+
the type list of the \IMPLEMENTS{} clause of $C$.
49294931

49304932
\rationale{%
49314933
One might argue that it is harmless to repeat a type in the superinterface list,
@@ -7751,15 +7753,9 @@ \subsubsection{Auxiliary Concepts for Instantiation to Bound}
77517753
Meta-variables
77527754
(\ref{metaVariables})
77537755
like $S$ and $T$ are understood to denote types,
7754-
and they are considered to be equal (as in `$S$ is $T$')
7755-
in the same sense as in the section about subtype rules
7756-
(\ref{subtypeRules}).
7757-
%
7758-
In particular,
7759-
even though two identical pieces of syntax may denote two distinct types,
7760-
and two different pieces of syntax may denote the same type,
7761-
the property of interest here is whether they denote the same type
7762-
and not whether they are spelled identically.
7756+
and they are considered to be or not be the same type
7757+
in the same sense as in the section about the type \code{Type}
7758+
(\ref{typeType}).
77637759

77647760
The intuition behind the situation where a type raw-depends on another type is
77657761
that we need to compute any missing type arguments for the latter
@@ -11230,9 +11226,10 @@ \subsubsection{Sets}
1123011226
$o_2$ with contents $o_{21}, \ldots, o_{2n}$ and actual type argument $t_2$
1123111227
be the result of evaluating them.
1123211228
Then \code{identical($o_1$, $o_2$)} evaluates to \TRUE{} if{}f
11233-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
11234-
\code{$t_1$ == $t_2$} and \code{identical($o_{1i}$, $o_{2i}$)}
11235-
evaluates to \TRUE{} for all $i \in 1 .. n$.
11229+
\code{identical($T_1$, $T_2$)} evaluates to \TRUE{}
11230+
(\ref{typeType}),
11231+
and \code{identical($o_{1i}$, $o_{2i}$)} evaluates to \TRUE{}
11232+
for all $i \in 1 .. n$.
1123611233

1123711234
\commentary{%
1123811235
In other words, constant set literals are canonicalized if they have
@@ -14883,9 +14880,9 @@ \subsubsection{Instance Method Closurization}
1488314880

1488414881
\LMHash{}%
1488514882
If $T$ is a non-generic class then for $j \in 1 .. n+k$,
14886-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
14887-
$T_j$ is a type annotation that denotes the same type as that
14888-
which is denoted by the type annotation on
14883+
$T_j$ is a type annotation that denotes the same type
14884+
(\ref{typeType})
14885+
as that which is denoted by the type annotation on
1488914886
the corresponding parameter declaration in $D$.
1489014887
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
1489114888

@@ -15037,9 +15034,9 @@ \subsubsection{Super Closurization}
1503715034

1503815035
\LMHash{}%
1503915036
If $S$ is a non-generic class then for $j \in 1 .. n+k$,
15040-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
15041-
$T_j$ is a type annotation that denotes the same type as that
15042-
which is denoted by the type annotation on
15037+
$T_j$ is a type annotation that denotes the same type
15038+
(\ref{typeType})
15039+
as that which is denoted by the type annotation on
1504315040
the corresponding parameter declaration in $D$.
1504415041
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
1504515042

@@ -15298,8 +15295,7 @@ \subsubsection{Generic Method Instantiation}
1529815295
Consider the situation where the program evaluates
1529915296
two invocations of this method with the same receiver $o$,
1530015297
and with actual type arguments whose actual values are
15301-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
15302-
the same types \List{t}{1}{s} for both invocations,
15298+
the same types (\ref{typeType}) \List{t}{1}{s} for both invocations,
1530315299
and assume that the invocations returned
1530415300
the instances $o_1$ respectively $o_2$.
1530515301
%
@@ -21504,7 +21500,8 @@ \subsubsection{Subtype Rules}
2150421500
\IndexCustom{instantiating}{instantiation!subtype rule}
2150521501
it, that is, by consistently replacing
2150621502
each occurrence of a given meta-variable by
21507-
concrete syntax denoting the same type.
21503+
concrete syntax denoting the same type
21504+
(\ref{typeType}).
2150821505

2150921506
\commentary{%
2151021507
In general, this means that two or more occurrences of
@@ -22004,7 +22001,7 @@ \subsection{Type Nullability}
2200422001
so it cannot be non-nullable.
2200522002

2200622003
It follows that all four concepts are distinct:
22007-
The same type $X$ is potentially nullable, but not nullable,
22004+
The given type $X$ is potentially nullable, but not nullable,
2200822005
and $X$ is also potentially non-nullable, but not non-nullable.%
2200922006
}
2201022007

@@ -22144,7 +22141,7 @@ \subsection{Functions Dealing with Extreme Types}
2214422141
\TopMergeTypeName{} of the first two,
2214522142
and then recursively taking \TopMergeTypeName{} of the rest.
2214622143
\commentary{The ordering of the arguments makes no difference.}
22147-
22144+
2214822145
\LMHash{}%
2214922146
The \Index{\IsTopTypeName} predicate is true for any type which is in
2215022147
the equivalence class of top types.
@@ -22160,7 +22157,7 @@ \subsection{Functions Dealing with Extreme Types}
2216022157
\end{itemize}
2216122158

2216222159
\noindent
22163-
The \Index{\IsObjectTypeName} predicate is true if{}f
22160+
The \Index{\IsObjectTypeName} predicate is true if{}f
2216422161
the argument is a subtype and a supertype of \code{Object}.
2216522162

2216622163
\begin{itemize}
@@ -22869,17 +22866,27 @@ \subsection{Type Type}
2286922866
We define what it means for two types to be the same as follows:
2287022867
Let $T_1$ and $T_2$ be types.
2287122868
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,
22869+
(\ref{typedef}) of $T_j$, for $j \in 1 .. 2$,
22870+
and let $S_j$ be \NormalizedTypeOf{$U_j$}, for $j \in 1 .. 2$
22871+
(\ref{typeNormalization}).
22872+
We then say that $T_1$ and $T_2$ are the \Index{same type}
22873+
if{}f $S_1$ and $S_2$ are syntactically equal,
2287722874
up to equivalence of bound variables,
2287822875
and up to replacement of identifiers or qualified identifiers
2287922876
resolving to the same type declaration
2288022877
(\commentary{%
2288122878
e.g., \code{C} and \code{prefix.C} could resolve to
2288222879
the same class declaration%
22880+
}),
22881+
and excluding the case where two identifiers or qualified identifiers
22882+
occurring at corresponding positions in $S_1$ and $S_2$
22883+
are syntactically identical,
22884+
but resolve to different declarations
22885+
(\commentary{%
22886+
e.g., one occurrence of \code{C} could resolve to a
22887+
class declaration imported from a library $L_1$,
22888+
and another occurrence of \code{C} could resolve to a
22889+
class declaration imported from a different library $L_2$%
2288322890
}).
2288422891

2288522892
\LMHash{}%
@@ -22927,9 +22934,9 @@ \subsection{Type Type}
2292722934
(\ref{constants})
2292822935
evaluating to $o_1$ respectively $o_2$,
2292922936
which are reified types reifying the types $T_1$ respecively $T_2$.
22930-
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
22937+
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$.
2293122938
We then have \code{identical($v_1$, $v_2$)} if{}f
22932-
\code{$T_1$\,\,==\,\,$T_2$}.
22939+
\code{$v_1$\,\,==\,\,$v_2$}.
2293322940

2293422941
\commentary{%
2293522942
In other words, constant reified types are canonicalized.
@@ -23549,22 +23556,22 @@ \subsubsection{Void Soundness}
2354923556
\ABSTRACT{} \CLASS A<X> \{
2355023557
final X x;
2355123558
A(this.x);
23552-
Object foo(X x);
23559+
Object? foo(X x);
2355323560
\}
2355423561
\\
2355523562
\CLASS{} B<X> \EXTENDS{} A<X> \{
2355623563
B(X x): super(x);
23557-
Object foo(Object x) => x;
23564+
Object? foo(Object? x) => x;
2355823565
\}
2355923566
\\
23560-
Object f<X>(X x) => x;
23567+
Object? f<X>(X x) => x;
2356123568
\\
2356223569
\VOID{} main() \{
2356323570
\VOID x = 42;
2356423571
print(f(x)); // \comment{(1)}
2356523572
\\
2356623573
A<\VOID{}> a = B<\VOID{}>(x);
23567-
A<Object> aObject = a;
23574+
A<Object?> aObject = a;
2356823575
print(aObject.x); // \comment{(2)}
2356923576
print(a.foo(x)); // \comment{(3)}
2357023577
\}
@@ -23581,25 +23588,25 @@ \subsubsection{Void Soundness}
2358123588
which is or contains a type variable whose value could be \VOID,
2358223589
so we are allowed to return \code{x} in the body of \code{f},
2358323590
even though this means that we indirectly get access to the value
23584-
of an expression of type \VOID, under the static type \code{Object}.
23591+
of an expression of type \VOID, under the static type \code{Object?}.
2358523592

2358623593
At (2), we indirectly obtain access to the value of
2358723594
the variable \code{x} with type \VOID,
2358823595
because we use an assignment to get access to the instance of \code{B}
2358923596
which was created with type argument \VOID{} under the type
23590-
\code{A<Object>}.
23591-
Note that \code{A<Object>} and \code{A<\VOID{}>} are subtypes of each other,
23597+
\code{A<Object?>}.
23598+
Note that \code{A<Object?>} and \code{A<\VOID{}>} are subtypes of each other,
2359223599
that is, they are equivalent according to the subtype rules,
2359323600
so neither static nor dynamic type checks will fail.
2359423601

2359523602
At (3), we indirectly obtain access to the value of
2359623603
the variable \code{x} with type \VOID{}
23597-
under the static type \code{Object},
23604+
under the static type \code{Object?},
2359823605
because the statically known method signature of \code{foo}
2359923606
has parameter type \VOID,
2360023607
but the actual implementation of \code{foo} which is invoked
23601-
is an override whose parameter type is \code{Object},
23602-
which is allowed because \code{Object} and \VOID{} are both top types.%
23608+
is an override whose parameter type is \code{Object?},
23609+
which is allowed because \code{Object?} and \VOID{} are both top types.%
2360323610
}
2360423611

2360523612
\rationale{%
@@ -23620,7 +23627,7 @@ \subsubsection{Void Soundness}
2362023627
from one variable or parameter to the next one, all with type \VOID,
2362123628
explicitly, or as the value of a type parameter.
2362223629
In particular, we could require that method overrides should
23623-
never override return type \code{Object} by return type \VOID,
23630+
never override return type \code{Object?} by return type \VOID,
2362423631
or parameter types in the opposite direction;
2362523632
parameterized types with type argument \VOID{} could not be assigned
2362623633
to variables where the corresponding type argument is anything other than

0 commit comments

Comments
 (0)