@@ -4971,9 +4971,11 @@ \subsection{Superinterfaces}
4971
4971
is not a class building type
4972
4972
(\ref{classBuildingTypes}).
4973
4973
It is a \Error{compile-time error} if two elements in said type list
4974
- specifies the same type.
4975
- It is a \Error{compile-time error} if the superclass of a class $C$ is
4976
- one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
4974
+ denotes the same type
4975
+ (\ref{typeType}).
4976
+ It is a \Error{compile-time error} if the superclass of a class $C$ denotes
4977
+ the same type as one of the elements of
4978
+ the type list of the \IMPLEMENTS{} clause of $C$.
4977
4979
4978
4980
\rationale{%
4979
4981
One might argue that it is harmless to repeat a type in the superinterface list,
@@ -7799,15 +7801,9 @@ \subsubsection{Auxiliary Concepts for Instantiation to Bound}
7799
7801
Meta-variables
7800
7802
(\ref{metaVariables})
7801
7803
like $S$ and $T$ are understood to denote types,
7802
- and they are considered to be equal (as in `$S$ is $T$')
7803
- in the same sense as in the section about subtype rules
7804
- (\ref{subtypeRules}).
7805
- %
7806
- In particular,
7807
- even though two identical pieces of syntax may denote two distinct types,
7808
- and two different pieces of syntax may denote the same type,
7809
- the property of interest here is whether they denote the same type
7810
- and not whether they are spelled identically.
7804
+ and they are considered to be or not be the same type
7805
+ in the same sense as in the section about the type \code{Type}
7806
+ (\ref{typeType}).
7811
7807
7812
7808
The intuition behind the situation where a type raw-depends on another type is
7813
7809
that we need to compute any missing type arguments for the latter
@@ -11300,9 +11296,10 @@ \subsubsection{Sets}
11300
11296
$o_2$ with contents $o_{21}, \ldots, o_{2n}$ and actual type argument $t_2$
11301
11297
be the result of evaluating them.
11302
11298
Then \code{identical($o_1$, $o_2$)} evaluates to \TRUE{} if{}f
11303
- %% TODO(eernst): Refer to nnbd notion of 'same type'.
11304
- \code{$t_1$ == $t_2$} and \code{identical($o_{1i}$, $o_{2i}$)}
11305
- evaluates to \TRUE{} for all $i \in 1 .. n$.
11299
+ \code{identical($T_1$, $T_2$)} evaluates to \TRUE{}
11300
+ (\ref{typeType}),
11301
+ and \code{identical($o_{1i}$, $o_{2i}$)} evaluates to \TRUE{}
11302
+ for all $i \in 1 .. n$.
11306
11303
11307
11304
\commentary{%
11308
11305
In other words, constant set literals are canonicalized if they have
@@ -15043,9 +15040,9 @@ \subsubsection{Instance Method Closurization}
15043
15040
15044
15041
\LMHash{}%
15045
15042
If $T$ is a non-generic class then for $j \in 1 .. n+k$,
15046
- %% TODO(eernst): Refer to nnbd notion of ' same type'.
15047
- $T_j$ is a type annotation that denotes the same type as that
15048
- which is denoted by the type annotation on
15043
+ $T_j$ is a type annotation that denotes the same type
15044
+ (\ref{typeType})
15045
+ as that which is denoted by the type annotation on
15049
15046
the corresponding parameter declaration in $D$.
15050
15047
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
15051
15048
@@ -15197,9 +15194,9 @@ \subsubsection{Super Closurization}
15197
15194
15198
15195
\LMHash{}%
15199
15196
If $S$ is a non-generic class then for $j \in 1 .. n+k$,
15200
- %% TODO(eernst): Refer to nnbd notion of ' same type'.
15201
- $T_j$ is a type annotation that denotes the same type as that
15202
- which is denoted by the type annotation on
15197
+ $T_j$ is a type annotation that denotes the same type
15198
+ (\ref{typeType})
15199
+ as that which is denoted by the type annotation on
15203
15200
the corresponding parameter declaration in $D$.
15204
15201
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
15205
15202
@@ -15458,8 +15455,7 @@ \subsubsection{Generic Method Instantiation}
15458
15455
Consider the situation where the program evaluates
15459
15456
two invocations of this method with the same receiver $o$,
15460
15457
and with actual type arguments whose actual values are
15461
- %% TODO(eernst): Refer to nnbd notion of 'same type'.
15462
- the same types \List{t}{1}{s} for both invocations,
15458
+ the same types (\ref{typeType}) \List{t}{1}{s} for both invocations,
15463
15459
and assume that the invocations returned
15464
15460
the instances $o_1$ respectively $o_2$.
15465
15461
%
@@ -21771,7 +21767,8 @@ \subsubsection{Subtype Rules}
21771
21767
\IndexCustom{instantiating}{instantiation!subtype rule}
21772
21768
it, that is, by consistently replacing
21773
21769
each occurrence of a given meta-variable by
21774
- concrete syntax denoting the same type.
21770
+ concrete syntax denoting the same type
21771
+ (\ref{typeType}).
21775
21772
21776
21773
\commentary{%
21777
21774
In general, this means that two or more occurrences of
@@ -22271,7 +22268,7 @@ \subsection{Type Nullability}
22271
22268
so it cannot be non-nullable.
22272
22269
22273
22270
It follows that all four concepts are distinct:
22274
- The same type $X$ is potentially nullable, but not nullable,
22271
+ The given type $X$ is potentially nullable, but not nullable,
22275
22272
and $X$ is also potentially non-nullable, but not non-nullable.%
22276
22273
}
22277
22274
@@ -22411,7 +22408,7 @@ \subsection{Functions Dealing with Extreme Types}
22411
22408
\TopMergeTypeName{} of the first two,
22412
22409
and then recursively taking \TopMergeTypeName{} of the rest.
22413
22410
\commentary{The ordering of the arguments makes no difference.}
22414
-
22411
+
22415
22412
\LMHash{}%
22416
22413
The \Index{\IsTopTypeName} predicate is true for any type which is in
22417
22414
the equivalence class of top types.
@@ -22427,7 +22424,7 @@ \subsection{Functions Dealing with Extreme Types}
22427
22424
\end{itemize}
22428
22425
22429
22426
\noindent
22430
- The \Index{\IsObjectTypeName} predicate is true if{}f
22427
+ The \Index{\IsObjectTypeName} predicate is true if{}f
22431
22428
the argument is a subtype and a supertype of \code{Object}.
22432
22429
22433
22430
\begin{itemize}
@@ -23136,17 +23133,27 @@ \subsection{Type Type}
23136
23133
We define what it means for two types to be the same as follows:
23137
23134
Let $T_1$ and $T_2$ be types.
23138
23135
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,
23136
+ (\ref{typedef}) of $T_j$, for $j \in 1 .. 2$,
23137
+ and let $S_j$ be \NormalizedTypeOf{$U_j$}, for $j \in 1 .. 2$
23138
+ (\ref{typeNormalization}).
23139
+ We then say that $T_1$ and $T_2$ are the \Index{same type}
23140
+ if{}f $S_1$ and $S_2$ are syntactically equal,
23144
23141
up to equivalence of bound variables,
23145
23142
and up to replacement of identifiers or qualified identifiers
23146
23143
resolving to the same type declaration
23147
23144
(\commentary{%
23148
23145
e.g., \code{C} and \code{prefix.C} could resolve to
23149
23146
the same class declaration%
23147
+ }),
23148
+ and excluding the case where two identifiers or qualified identifiers
23149
+ occurring at corresponding positions in $S_1$ and $S_2$
23150
+ are syntactically identical,
23151
+ but resolve to different declarations
23152
+ (\commentary{%
23153
+ e.g., one occurrence of \code{C} could resolve to a
23154
+ class declaration imported from a library $L_1$,
23155
+ and another occurrence of \code{C} could resolve to a
23156
+ class declaration imported from a different library $L_2$%
23150
23157
}).
23151
23158
23152
23159
\LMHash{}%
@@ -23194,9 +23201,9 @@ \subsection{Type Type}
23194
23201
(\ref{constants})
23195
23202
evaluating to $o_1$ respectively $o_2$,
23196
23203
which are reified types reifying the types $T_1$ respecively $T_2$.
23197
- Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
23204
+ Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$.
23198
23205
We then have \code{identical($v_1$, $v_2$)} if{}f
23199
- \code{$T_1 $\,\,==\,\,$T_2 $}.
23206
+ \code{$v_1 $\,\,==\,\,$v_2 $}.
23200
23207
23201
23208
\commentary{%
23202
23209
In other words, constant reified types are canonicalized.
@@ -23816,22 +23823,22 @@ \subsubsection{Void Soundness}
23816
23823
\ABSTRACT{} \CLASS A<X> \{
23817
23824
final X x;
23818
23825
A(this.x);
23819
- Object foo(X x);
23826
+ Object? foo(X x);
23820
23827
\}
23821
23828
\\
23822
23829
\CLASS{} B<X> \EXTENDS{} A<X> \{
23823
23830
B(X x): super(x);
23824
- Object foo(Object x) => x;
23831
+ Object? foo(Object? x) => x;
23825
23832
\}
23826
23833
\\
23827
- Object f<X>(X x) => x;
23834
+ Object? f<X>(X x) => x;
23828
23835
\\
23829
23836
\VOID{} main() \{
23830
23837
\VOID x = 42;
23831
23838
print(f(x)); // \comment{(1)}
23832
23839
\\
23833
23840
A<\VOID{}> a = B<\VOID{}>(x);
23834
- A<Object> aObject = a;
23841
+ A<Object? > aObject = a;
23835
23842
print(aObject.x); // \comment{(2)}
23836
23843
print(a.foo(x)); // \comment{(3)}
23837
23844
\}
@@ -23848,25 +23855,25 @@ \subsubsection{Void Soundness}
23848
23855
which is or contains a type variable whose value could be \VOID,
23849
23856
so we are allowed to return \code{x} in the body of \code{f},
23850
23857
even though this means that we indirectly get access to the value
23851
- of an expression of type \VOID, under the static type \code{Object}.
23858
+ of an expression of type \VOID, under the static type \code{Object? }.
23852
23859
23853
23860
At (2), we indirectly obtain access to the value of
23854
23861
the variable \code{x} with type \VOID,
23855
23862
because we use an assignment to get access to the instance of \code{B}
23856
23863
which was created with type argument \VOID{} under the type
23857
- \code{A<Object>}.
23858
- Note that \code{A<Object>} and \code{A<\VOID{}>} are subtypes of each other,
23864
+ \code{A<Object? >}.
23865
+ Note that \code{A<Object? >} and \code{A<\VOID{}>} are subtypes of each other,
23859
23866
that is, they are equivalent according to the subtype rules,
23860
23867
so neither static nor dynamic type checks will fail.
23861
23868
23862
23869
At (3), we indirectly obtain access to the value of
23863
23870
the variable \code{x} with type \VOID{}
23864
- under the static type \code{Object},
23871
+ under the static type \code{Object? },
23865
23872
because the statically known method signature of \code{foo}
23866
23873
has parameter type \VOID,
23867
23874
but the actual implementation of \code{foo} which is invoked
23868
- is an override whose parameter type is \code{Object},
23869
- which is allowed because \code{Object} and \VOID{} are both top types.%
23875
+ is an override whose parameter type is \code{Object? },
23876
+ which is allowed because \code{Object? } and \VOID{} are both top types.%
23870
23877
}
23871
23878
23872
23879
\rationale{%
@@ -23887,7 +23894,7 @@ \subsubsection{Void Soundness}
23887
23894
from one variable or parameter to the next one, all with type \VOID,
23888
23895
explicitly, or as the value of a type parameter.
23889
23896
In particular, we could require that method overrides should
23890
- never override return type \code{Object} by return type \VOID,
23897
+ never override return type \code{Object? } by return type \VOID,
23891
23898
or parameter types in the opposite direction;
23892
23899
parameterized types with type argument \VOID{} could not be assigned
23893
23900
to variables where the corresponding type argument is anything other than
0 commit comments