@@ -4923,9 +4923,11 @@ \subsection{Superinterfaces}
4923
4923
is not a class building type
4924
4924
(\ref{classBuildingTypes}).
4925
4925
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$.
4929
4931
4930
4932
\rationale{%
4931
4933
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}
7751
7753
Meta-variables
7752
7754
(\ref{metaVariables})
7753
7755
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}).
7763
7759
7764
7760
The intuition behind the situation where a type raw-depends on another type is
7765
7761
that we need to compute any missing type arguments for the latter
@@ -11230,9 +11226,10 @@ \subsubsection{Sets}
11230
11226
$o_2$ with contents $o_{21}, \ldots, o_{2n}$ and actual type argument $t_2$
11231
11227
be the result of evaluating them.
11232
11228
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$.
11236
11233
11237
11234
\commentary{%
11238
11235
In other words, constant set literals are canonicalized if they have
@@ -14883,9 +14880,9 @@ \subsubsection{Instance Method Closurization}
14883
14880
14884
14881
\LMHash{}%
14885
14882
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
14889
14886
the corresponding parameter declaration in $D$.
14890
14887
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
14891
14888
@@ -15037,9 +15034,9 @@ \subsubsection{Super Closurization}
15037
15034
15038
15035
\LMHash{}%
15039
15036
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
15043
15040
the corresponding parameter declaration in $D$.
15044
15041
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
15045
15042
@@ -15298,8 +15295,7 @@ \subsubsection{Generic Method Instantiation}
15298
15295
Consider the situation where the program evaluates
15299
15296
two invocations of this method with the same receiver $o$,
15300
15297
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,
15303
15299
and assume that the invocations returned
15304
15300
the instances $o_1$ respectively $o_2$.
15305
15301
%
@@ -21504,7 +21500,8 @@ \subsubsection{Subtype Rules}
21504
21500
\IndexCustom{instantiating}{instantiation!subtype rule}
21505
21501
it, that is, by consistently replacing
21506
21502
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}).
21508
21505
21509
21506
\commentary{%
21510
21507
In general, this means that two or more occurrences of
@@ -22004,7 +22001,7 @@ \subsection{Type Nullability}
22004
22001
so it cannot be non-nullable.
22005
22002
22006
22003
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,
22008
22005
and $X$ is also potentially non-nullable, but not non-nullable.%
22009
22006
}
22010
22007
@@ -22144,7 +22141,7 @@ \subsection{Functions Dealing with Extreme Types}
22144
22141
\TopMergeTypeName{} of the first two,
22145
22142
and then recursively taking \TopMergeTypeName{} of the rest.
22146
22143
\commentary{The ordering of the arguments makes no difference.}
22147
-
22144
+
22148
22145
\LMHash{}%
22149
22146
The \Index{\IsTopTypeName} predicate is true for any type which is in
22150
22147
the equivalence class of top types.
@@ -22160,7 +22157,7 @@ \subsection{Functions Dealing with Extreme Types}
22160
22157
\end{itemize}
22161
22158
22162
22159
\noindent
22163
- The \Index{\IsObjectTypeName} predicate is true if{}f
22160
+ The \Index{\IsObjectTypeName} predicate is true if{}f
22164
22161
the argument is a subtype and a supertype of \code{Object}.
22165
22162
22166
22163
\begin{itemize}
@@ -22869,17 +22866,27 @@ \subsection{Type Type}
22869
22866
We define what it means for two types to be the same as follows:
22870
22867
Let $T_1$ and $T_2$ be types.
22871
22868
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,
22877
22874
up to equivalence of bound variables,
22878
22875
and up to replacement of identifiers or qualified identifiers
22879
22876
resolving to the same type declaration
22880
22877
(\commentary{%
22881
22878
e.g., \code{C} and \code{prefix.C} could resolve to
22882
22879
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$%
22883
22890
}).
22884
22891
22885
22892
\LMHash{}%
@@ -22927,9 +22934,9 @@ \subsection{Type Type}
22927
22934
(\ref{constants})
22928
22935
evaluating to $o_1$ respectively $o_2$,
22929
22936
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$.
22931
22938
We then have \code{identical($v_1$, $v_2$)} if{}f
22932
- \code{$T_1 $\,\,==\,\,$T_2 $}.
22939
+ \code{$v_1 $\,\,==\,\,$v_2 $}.
22933
22940
22934
22941
\commentary{%
22935
22942
In other words, constant reified types are canonicalized.
@@ -23549,22 +23556,22 @@ \subsubsection{Void Soundness}
23549
23556
\ABSTRACT{} \CLASS A<X> \{
23550
23557
final X x;
23551
23558
A(this.x);
23552
- Object foo(X x);
23559
+ Object? foo(X x);
23553
23560
\}
23554
23561
\\
23555
23562
\CLASS{} B<X> \EXTENDS{} A<X> \{
23556
23563
B(X x): super(x);
23557
- Object foo(Object x) => x;
23564
+ Object? foo(Object? x) => x;
23558
23565
\}
23559
23566
\\
23560
- Object f<X>(X x) => x;
23567
+ Object? f<X>(X x) => x;
23561
23568
\\
23562
23569
\VOID{} main() \{
23563
23570
\VOID x = 42;
23564
23571
print(f(x)); // \comment{(1)}
23565
23572
\\
23566
23573
A<\VOID{}> a = B<\VOID{}>(x);
23567
- A<Object> aObject = a;
23574
+ A<Object? > aObject = a;
23568
23575
print(aObject.x); // \comment{(2)}
23569
23576
print(a.foo(x)); // \comment{(3)}
23570
23577
\}
@@ -23581,25 +23588,25 @@ \subsubsection{Void Soundness}
23581
23588
which is or contains a type variable whose value could be \VOID,
23582
23589
so we are allowed to return \code{x} in the body of \code{f},
23583
23590
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? }.
23585
23592
23586
23593
At (2), we indirectly obtain access to the value of
23587
23594
the variable \code{x} with type \VOID,
23588
23595
because we use an assignment to get access to the instance of \code{B}
23589
23596
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,
23592
23599
that is, they are equivalent according to the subtype rules,
23593
23600
so neither static nor dynamic type checks will fail.
23594
23601
23595
23602
At (3), we indirectly obtain access to the value of
23596
23603
the variable \code{x} with type \VOID{}
23597
- under the static type \code{Object},
23604
+ under the static type \code{Object? },
23598
23605
because the statically known method signature of \code{foo}
23599
23606
has parameter type \VOID,
23600
23607
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.%
23603
23610
}
23604
23611
23605
23612
\rationale{%
@@ -23620,7 +23627,7 @@ \subsubsection{Void Soundness}
23620
23627
from one variable or parameter to the next one, all with type \VOID,
23621
23628
explicitly, or as the value of a type parameter.
23622
23629
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,
23624
23631
or parameter types in the opposite direction;
23625
23632
parameterized types with type argument \VOID{} could not be assigned
23626
23633
to variables where the corresponding type argument is anything other than
0 commit comments