@@ -4963,9 +4963,11 @@ \subsection{Superinterfaces}
4963
4963
is not a class building type
4964
4964
(\ref{classBuildingTypes}).
4965
4965
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$.
4969
4971
4970
4972
\rationale{%
4971
4973
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}
7791
7793
Meta-variables
7792
7794
(\ref{metaVariables})
7793
7795
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}).
7803
7799
7804
7800
The intuition behind the situation where a type raw-depends on another type is
7805
7801
that we need to compute any missing type arguments for the latter
@@ -11286,9 +11282,10 @@ \subsubsection{Sets}
11286
11282
$o_2$ with contents $o_{21}, \ldots, o_{2n}$ and actual type argument $t_2$
11287
11283
be the result of evaluating them.
11288
11284
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$.
11292
11289
11293
11290
\commentary{%
11294
11291
In other words, constant set literals are canonicalized if they have
@@ -14971,9 +14968,9 @@ \subsubsection{Instance Method Closurization}
14971
14968
14972
14969
\LMHash{}%
14973
14970
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
14977
14974
the corresponding parameter declaration in $D$.
14978
14975
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
14979
14976
@@ -15125,9 +15122,9 @@ \subsubsection{Super Closurization}
15125
15122
15126
15123
\LMHash{}%
15127
15124
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
15131
15128
the corresponding parameter declaration in $D$.
15132
15129
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
15133
15130
@@ -15386,8 +15383,7 @@ \subsubsection{Generic Method Instantiation}
15386
15383
Consider the situation where the program evaluates
15387
15384
two invocations of this method with the same receiver $o$,
15388
15385
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,
15391
15387
and assume that the invocations returned
15392
15388
the instances $o_1$ respectively $o_2$.
15393
15389
%
@@ -21633,7 +21629,8 @@ \subsubsection{Subtype Rules}
21633
21629
\IndexCustom{instantiating}{instantiation!subtype rule}
21634
21630
it, that is, by consistently replacing
21635
21631
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}).
21637
21634
21638
21635
\commentary{%
21639
21636
In general, this means that two or more occurrences of
@@ -22133,7 +22130,7 @@ \subsection{Type Nullability}
22133
22130
so it cannot be non-nullable.
22134
22131
22135
22132
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,
22137
22134
and $X$ is also potentially non-nullable, but not non-nullable.%
22138
22135
}
22139
22136
@@ -22273,7 +22270,7 @@ \subsection{Functions Dealing with Extreme Types}
22273
22270
\TopMergeTypeName{} of the first two,
22274
22271
and then recursively taking \TopMergeTypeName{} of the rest.
22275
22272
\commentary{The ordering of the arguments makes no difference.}
22276
-
22273
+
22277
22274
\LMHash{}%
22278
22275
The \Index{\IsTopTypeName} predicate is true for any type which is in
22279
22276
the equivalence class of top types.
@@ -22289,7 +22286,7 @@ \subsection{Functions Dealing with Extreme Types}
22289
22286
\end{itemize}
22290
22287
22291
22288
\noindent
22292
- The \Index{\IsObjectTypeName} predicate is true if{}f
22289
+ The \Index{\IsObjectTypeName} predicate is true if{}f
22293
22290
the argument is a subtype and a supertype of \code{Object}.
22294
22291
22295
22292
\begin{itemize}
@@ -22998,17 +22995,27 @@ \subsection{Type Type}
22998
22995
We define what it means for two types to be the same as follows:
22999
22996
Let $T_1$ and $T_2$ be types.
23000
22997
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,
23006
23003
up to equivalence of bound variables,
23007
23004
and up to replacement of identifiers or qualified identifiers
23008
23005
resolving to the same type declaration
23009
23006
(\commentary{%
23010
23007
e.g., \code{C} and \code{prefix.C} could resolve to
23011
23008
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$%
23012
23019
}).
23013
23020
23014
23021
\LMHash{}%
@@ -23056,9 +23063,9 @@ \subsection{Type Type}
23056
23063
(\ref{constants})
23057
23064
evaluating to $o_1$ respectively $o_2$,
23058
23065
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$.
23060
23067
We then have \code{identical($v_1$, $v_2$)} if{}f
23061
- \code{$T_1 $\,\,==\,\,$T_2 $}.
23068
+ \code{$v_1 $\,\,==\,\,$v_2 $}.
23062
23069
23063
23070
\commentary{%
23064
23071
In other words, constant reified types are canonicalized.
@@ -23678,22 +23685,22 @@ \subsubsection{Void Soundness}
23678
23685
\ABSTRACT{} \CLASS A<X> \{
23679
23686
final X x;
23680
23687
A(this.x);
23681
- Object foo(X x);
23688
+ Object? foo(X x);
23682
23689
\}
23683
23690
\\
23684
23691
\CLASS{} B<X> \EXTENDS{} A<X> \{
23685
23692
B(X x): super(x);
23686
- Object foo(Object x) => x;
23693
+ Object? foo(Object? x) => x;
23687
23694
\}
23688
23695
\\
23689
- Object f<X>(X x) => x;
23696
+ Object? f<X>(X x) => x;
23690
23697
\\
23691
23698
\VOID{} main() \{
23692
23699
\VOID x = 42;
23693
23700
print(f(x)); // \comment{(1)}
23694
23701
\\
23695
23702
A<\VOID{}> a = B<\VOID{}>(x);
23696
- A<Object> aObject = a;
23703
+ A<Object? > aObject = a;
23697
23704
print(aObject.x); // \comment{(2)}
23698
23705
print(a.foo(x)); // \comment{(3)}
23699
23706
\}
@@ -23710,25 +23717,25 @@ \subsubsection{Void Soundness}
23710
23717
which is or contains a type variable whose value could be \VOID,
23711
23718
so we are allowed to return \code{x} in the body of \code{f},
23712
23719
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? }.
23714
23721
23715
23722
At (2), we indirectly obtain access to the value of
23716
23723
the variable \code{x} with type \VOID,
23717
23724
because we use an assignment to get access to the instance of \code{B}
23718
23725
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,
23721
23728
that is, they are equivalent according to the subtype rules,
23722
23729
so neither static nor dynamic type checks will fail.
23723
23730
23724
23731
At (3), we indirectly obtain access to the value of
23725
23732
the variable \code{x} with type \VOID{}
23726
- under the static type \code{Object},
23733
+ under the static type \code{Object? },
23727
23734
because the statically known method signature of \code{foo}
23728
23735
has parameter type \VOID,
23729
23736
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.%
23732
23739
}
23733
23740
23734
23741
\rationale{%
@@ -23749,7 +23756,7 @@ \subsubsection{Void Soundness}
23749
23756
from one variable or parameter to the next one, all with type \VOID,
23750
23757
explicitly, or as the value of a type parameter.
23751
23758
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,
23753
23760
or parameter types in the opposite direction;
23754
23761
parameterized types with type argument \VOID{} could not be assigned
23755
23762
to variables where the corresponding type argument is anything other than
0 commit comments