Skip to content

Commit 0b2e748

Browse files
committed
More typeType fixes
1 parent 94cbd4b commit 0b2e748

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
@@ -4963,9 +4963,11 @@ \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-
specifies the same type.
4967-
It is a \Error{compile-time error} if the superclass of a class $C$ is
4968-
one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
4966+
denotes the same type
4967+
(\ref{typeType}).
4968+
It is a \Error{compile-time error} if the superclass of a class $C$ denotes
4969+
the same type as one of the elements of
4970+
the type list of the \IMPLEMENTS{} clause of $C$.
49694971

49704972
\rationale{%
49714973
One might argue that it is harmless to repeat a type in the superinterface list,
@@ -7791,15 +7793,9 @@ \subsubsection{Auxiliary Concepts for Instantiation to Bound}
77917793
Meta-variables
77927794
(\ref{metaVariables})
77937795
like $S$ and $T$ are understood to denote types,
7794-
and they are considered to be equal (as in `$S$ is $T$')
7795-
in the same sense as in the section about subtype rules
7796-
(\ref{subtypeRules}).
7797-
%
7798-
In particular,
7799-
even though two identical pieces of syntax may denote two distinct types,
7800-
and two different pieces of syntax may denote the same type,
7801-
the property of interest here is whether they denote the same type
7802-
and not whether they are spelled identically.
7796+
and they are considered to be or not be the same type
7797+
in the same sense as in the section about the type \code{Type}
7798+
(\ref{typeType}).
78037799

78047800
The intuition behind the situation where a type raw-depends on another type is
78057801
that we need to compute any missing type arguments for the latter
@@ -11286,9 +11282,10 @@ \subsubsection{Sets}
1128611282
$o_2$ with contents $o_{21}, \ldots, o_{2n}$ and actual type argument $t_2$
1128711283
be the result of evaluating them.
1128811284
Then \code{identical($o_1$, $o_2$)} evaluates to \TRUE{} if{}f
11289-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
11290-
\code{$t_1$ == $t_2$} and \code{identical($o_{1i}$, $o_{2i}$)}
11291-
evaluates to \TRUE{} for all $i \in 1 .. n$.
11285+
\code{identical($T_1$, $T_2$)} evaluates to \TRUE{}
11286+
(\ref{typeType}),
11287+
and \code{identical($o_{1i}$, $o_{2i}$)} evaluates to \TRUE{}
11288+
for all $i \in 1 .. n$.
1129211289

1129311290
\commentary{%
1129411291
In other words, constant set literals are canonicalized if they have
@@ -14971,9 +14968,9 @@ \subsubsection{Instance Method Closurization}
1497114968

1497214969
\LMHash{}%
1497314970
If $T$ is a non-generic class then for $j \in 1 .. n+k$,
14974-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
14975-
$T_j$ is a type annotation that denotes the same type as that
14976-
which is denoted by the type annotation on
14971+
$T_j$ is a type annotation that denotes the same type
14972+
(\ref{typeType})
14973+
as that which is denoted by the type annotation on
1497714974
the corresponding parameter declaration in $D$.
1497814975
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
1497914976

@@ -15125,9 +15122,9 @@ \subsubsection{Super Closurization}
1512515122

1512615123
\LMHash{}%
1512715124
If $S$ is a non-generic class then for $j \in 1 .. n+k$,
15128-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
15129-
$T_j$ is a type annotation that denotes the same type as that
15130-
which is denoted by the type annotation on
15125+
$T_j$ is a type annotation that denotes the same type
15126+
(\ref{typeType})
15127+
as that which is denoted by the type annotation on
1513115128
the corresponding parameter declaration in $D$.
1513215129
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
1513315130

@@ -15386,8 +15383,7 @@ \subsubsection{Generic Method Instantiation}
1538615383
Consider the situation where the program evaluates
1538715384
two invocations of this method with the same receiver $o$,
1538815385
and with actual type arguments whose actual values are
15389-
%% TODO(eernst): Refer to nnbd notion of 'same type'.
15390-
the same types \List{t}{1}{s} for both invocations,
15386+
the same types (\ref{typeType}) \List{t}{1}{s} for both invocations,
1539115387
and assume that the invocations returned
1539215388
the instances $o_1$ respectively $o_2$.
1539315389
%
@@ -21633,7 +21629,8 @@ \subsubsection{Subtype Rules}
2163321629
\IndexCustom{instantiating}{instantiation!subtype rule}
2163421630
it, that is, by consistently replacing
2163521631
each occurrence of a given meta-variable by
21636-
concrete syntax denoting the same type.
21632+
concrete syntax denoting the same type
21633+
(\ref{typeType}).
2163721634

2163821635
\commentary{%
2163921636
In general, this means that two or more occurrences of
@@ -22133,7 +22130,7 @@ \subsection{Type Nullability}
2213322130
so it cannot be non-nullable.
2213422131

2213522132
It follows that all four concepts are distinct:
22136-
The same type $X$ is potentially nullable, but not nullable,
22133+
The given type $X$ is potentially nullable, but not nullable,
2213722134
and $X$ is also potentially non-nullable, but not non-nullable.%
2213822135
}
2213922136

@@ -22273,7 +22270,7 @@ \subsection{Functions Dealing with Extreme Types}
2227322270
\TopMergeTypeName{} of the first two,
2227422271
and then recursively taking \TopMergeTypeName{} of the rest.
2227522272
\commentary{The ordering of the arguments makes no difference.}
22276-
22273+
2227722274
\LMHash{}%
2227822275
The \Index{\IsTopTypeName} predicate is true for any type which is in
2227922276
the equivalence class of top types.
@@ -22289,7 +22286,7 @@ \subsection{Functions Dealing with Extreme Types}
2228922286
\end{itemize}
2229022287

2229122288
\noindent
22292-
The \Index{\IsObjectTypeName} predicate is true if{}f
22289+
The \Index{\IsObjectTypeName} predicate is true if{}f
2229322290
the argument is a subtype and a supertype of \code{Object}.
2229422291

2229522292
\begin{itemize}
@@ -22998,17 +22995,27 @@ \subsection{Type Type}
2299822995
We define what it means for two types to be the same as follows:
2299922996
Let $T_1$ and $T_2$ be types.
2300022997
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,
22998+
(\ref{typedef}) of $T_j$, for $j \in 1 .. 2$,
22999+
and let $S_j$ be \NormalizedTypeOf{$U_j$}, for $j \in 1 .. 2$
23000+
(\ref{typeNormalization}).
23001+
We then say that $T_1$ and $T_2$ are the \Index{same type}
23002+
if{}f $S_1$ and $S_2$ are syntactically equal,
2300623003
up to equivalence of bound variables,
2300723004
and up to replacement of identifiers or qualified identifiers
2300823005
resolving to the same type declaration
2300923006
(\commentary{%
2301023007
e.g., \code{C} and \code{prefix.C} could resolve to
2301123008
the same class declaration%
23009+
}),
23010+
and excluding the case where two identifiers or qualified identifiers
23011+
occurring at corresponding positions in $S_1$ and $S_2$
23012+
are syntactically identical,
23013+
but resolve to different declarations
23014+
(\commentary{%
23015+
e.g., one occurrence of \code{C} could resolve to a
23016+
class declaration imported from a library $L_1$,
23017+
and another occurrence of \code{C} could resolve to a
23018+
class declaration imported from a different library $L_2$%
2301223019
}).
2301323020

2301423021
\LMHash{}%
@@ -23056,9 +23063,9 @@ \subsection{Type Type}
2305623063
(\ref{constants})
2305723064
evaluating to $o_1$ respectively $o_2$,
2305823065
which are reified types reifying the types $T_1$ respecively $T_2$.
23059-
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
23066+
Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$.
2306023067
We then have \code{identical($v_1$, $v_2$)} if{}f
23061-
\code{$T_1$\,\,==\,\,$T_2$}.
23068+
\code{$v_1$\,\,==\,\,$v_2$}.
2306223069

2306323070
\commentary{%
2306423071
In other words, constant reified types are canonicalized.
@@ -23678,22 +23685,22 @@ \subsubsection{Void Soundness}
2367823685
\ABSTRACT{} \CLASS A<X> \{
2367923686
final X x;
2368023687
A(this.x);
23681-
Object foo(X x);
23688+
Object? foo(X x);
2368223689
\}
2368323690
\\
2368423691
\CLASS{} B<X> \EXTENDS{} A<X> \{
2368523692
B(X x): super(x);
23686-
Object foo(Object x) => x;
23693+
Object? foo(Object? x) => x;
2368723694
\}
2368823695
\\
23689-
Object f<X>(X x) => x;
23696+
Object? f<X>(X x) => x;
2369023697
\\
2369123698
\VOID{} main() \{
2369223699
\VOID x = 42;
2369323700
print(f(x)); // \comment{(1)}
2369423701
\\
2369523702
A<\VOID{}> a = B<\VOID{}>(x);
23696-
A<Object> aObject = a;
23703+
A<Object?> aObject = a;
2369723704
print(aObject.x); // \comment{(2)}
2369823705
print(a.foo(x)); // \comment{(3)}
2369923706
\}
@@ -23710,25 +23717,25 @@ \subsubsection{Void Soundness}
2371023717
which is or contains a type variable whose value could be \VOID,
2371123718
so we are allowed to return \code{x} in the body of \code{f},
2371223719
even though this means that we indirectly get access to the value
23713-
of an expression of type \VOID, under the static type \code{Object}.
23720+
of an expression of type \VOID, under the static type \code{Object?}.
2371423721

2371523722
At (2), we indirectly obtain access to the value of
2371623723
the variable \code{x} with type \VOID,
2371723724
because we use an assignment to get access to the instance of \code{B}
2371823725
which was created with type argument \VOID{} under the type
23719-
\code{A<Object>}.
23720-
Note that \code{A<Object>} and \code{A<\VOID{}>} are subtypes of each other,
23726+
\code{A<Object?>}.
23727+
Note that \code{A<Object?>} and \code{A<\VOID{}>} are subtypes of each other,
2372123728
that is, they are equivalent according to the subtype rules,
2372223729
so neither static nor dynamic type checks will fail.
2372323730

2372423731
At (3), we indirectly obtain access to the value of
2372523732
the variable \code{x} with type \VOID{}
23726-
under the static type \code{Object},
23733+
under the static type \code{Object?},
2372723734
because the statically known method signature of \code{foo}
2372823735
has parameter type \VOID,
2372923736
but the actual implementation of \code{foo} which is invoked
23730-
is an override whose parameter type is \code{Object},
23731-
which is allowed because \code{Object} and \VOID{} are both top types.%
23737+
is an override whose parameter type is \code{Object?},
23738+
which is allowed because \code{Object?} and \VOID{} are both top types.%
2373223739
}
2373323740

2373423741
\rationale{%
@@ -23749,7 +23756,7 @@ \subsubsection{Void Soundness}
2374923756
from one variable or parameter to the next one, all with type \VOID,
2375023757
explicitly, or as the value of a type parameter.
2375123758
In particular, we could require that method overrides should
23752-
never override return type \code{Object} by return type \VOID,
23759+
never override return type \code{Object?} by return type \VOID,
2375323760
or parameter types in the opposite direction;
2375423761
parameterized types with type argument \VOID{} could not be assigned
2375523762
to variables where the corresponding type argument is anything other than

0 commit comments

Comments
 (0)