@@ -5149,9 +5149,11 @@ \subsection{Superinterfaces}
5149
5149
is not a class building type
5150
5150
(\ref{classBuildingTypes}).
5151
5151
It is a \Error{compile-time error} if two elements in said type list
5152
- specifies the same type.
5153
- It is a \Error{compile-time error} if the superclass of a class $C$ is
5154
- one of the elements of the type list of the \IMPLEMENTS{} clause of $C$.
5152
+ denotes the same type
5153
+ (\ref{typeType}).
5154
+ It is a \Error{compile-time error} if the superclass of a class $C$ denotes
5155
+ the same type as one of the elements of
5156
+ the type list of the \IMPLEMENTS{} clause of $C$.
5155
5157
5156
5158
\rationale{%
5157
5159
One might argue that it is harmless to repeat a type in the superinterface list,
@@ -7977,15 +7979,9 @@ \subsubsection{Auxiliary Concepts for Instantiation to Bound}
7977
7979
Meta-variables
7978
7980
(\ref{metaVariables})
7979
7981
like $S$ and $T$ are understood to denote types,
7980
- and they are considered to be equal (as in `$S$ is $T$')
7981
- in the same sense as in the section about subtype rules
7982
- (\ref{subtypeRules}).
7983
- %
7984
- In particular,
7985
- even though two identical pieces of syntax may denote two distinct types,
7986
- and two different pieces of syntax may denote the same type,
7987
- the property of interest here is whether they denote the same type
7988
- and not whether they are spelled identically.
7982
+ and they are considered to be or not be the same type
7983
+ in the same sense as in the section about the type \code{Type}
7984
+ (\ref{typeType}).
7989
7985
7990
7986
The intuition behind the situation where a type raw-depends on another type is
7991
7987
that we need to compute any missing type arguments for the latter
@@ -11478,9 +11474,10 @@ \subsubsection{Sets}
11478
11474
$o_2$ with contents $o_{21}, \ldots, o_{2n}$ and actual type argument $t_2$
11479
11475
be the result of evaluating them.
11480
11476
Then \code{identical($o_1$, $o_2$)} evaluates to \TRUE{} if{}f
11481
- %% TODO(eernst): Refer to nnbd notion of 'same type'.
11482
- \code{$t_1$ == $t_2$} and \code{identical($o_{1i}$, $o_{2i}$)}
11483
- evaluates to \TRUE{} for all $i \in 1 .. n$.
11477
+ \code{identical($T_1$, $T_2$)} evaluates to \TRUE{}
11478
+ (\ref{typeType}),
11479
+ and \code{identical($o_{1i}$, $o_{2i}$)} evaluates to \TRUE{}
11480
+ for all $i \in 1 .. n$.
11484
11481
11485
11482
\commentary{%
11486
11483
In other words, constant set literals are canonicalized if they have
@@ -15227,9 +15224,9 @@ \subsubsection{Instance Method Closurization}
15227
15224
15228
15225
\LMHash{}%
15229
15226
If $T$ is a non-generic class then for $j \in 1 .. n+k$,
15230
- %% TODO(eernst): Refer to nnbd notion of ' same type'.
15231
- $T_j$ is a type annotation that denotes the same type as that
15232
- which is denoted by the type annotation on
15227
+ $T_j$ is a type annotation that denotes the same type
15228
+ (\ref{typeType})
15229
+ as that which is denoted by the type annotation on
15233
15230
the corresponding parameter declaration in $D$.
15234
15231
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
15235
15232
@@ -15381,9 +15378,9 @@ \subsubsection{Super Closurization}
15381
15378
15382
15379
\LMHash{}%
15383
15380
If $S$ is a non-generic class then for $j \in 1 .. n+k$,
15384
- %% TODO(eernst): Refer to nnbd notion of ' same type'.
15385
- $T_j$ is a type annotation that denotes the same type as that
15386
- which is denoted by the type annotation on
15381
+ $T_j$ is a type annotation that denotes the same type
15382
+ (\ref{typeType})
15383
+ as that which is denoted by the type annotation on
15387
15384
the corresponding parameter declaration in $D$.
15388
15385
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
15389
15386
@@ -15642,8 +15639,7 @@ \subsubsection{Generic Method Instantiation}
15642
15639
Consider the situation where the program evaluates
15643
15640
two invocations of this method with the same receiver $o$,
15644
15641
and with actual type arguments whose actual values are
15645
- %% TODO(eernst): Refer to nnbd notion of 'same type'.
15646
- the same types \List{t}{1}{s} for both invocations,
15642
+ the same types (\ref{typeType}) \List{t}{1}{s} for both invocations,
15647
15643
and assume that the invocations returned
15648
15644
the instances $o_1$ respectively $o_2$.
15649
15645
%
@@ -22007,7 +22003,8 @@ \subsubsection{Subtype Rules}
22007
22003
\IndexCustom{instantiating}{instantiation!subtype rule}
22008
22004
it, that is, by consistently replacing
22009
22005
each occurrence of a given meta-variable by
22010
- concrete syntax denoting the same type.
22006
+ concrete syntax denoting the same type
22007
+ (\ref{typeType}).
22011
22008
22012
22009
\commentary{%
22013
22010
In general, this means that two or more occurrences of
@@ -22509,7 +22506,7 @@ \subsection{Type Nullability}
22509
22506
so it cannot be non-nullable.
22510
22507
22511
22508
It follows that all four concepts are distinct:
22512
- The same type $X$ is potentially nullable, but not nullable,
22509
+ The given type $X$ is potentially nullable, but not nullable,
22513
22510
and $X$ is also potentially non-nullable, but not non-nullable.%
22514
22511
}
22515
22512
@@ -22649,7 +22646,7 @@ \subsection{Functions Dealing with Extreme Types}
22649
22646
\TopMergeTypeName{} of the first two,
22650
22647
and then recursively taking \TopMergeTypeName{} of the rest.
22651
22648
\commentary{The ordering of the arguments makes no difference.}
22652
-
22649
+
22653
22650
\LMHash{}%
22654
22651
The \Index{\IsTopTypeName} predicate is true for any type which is in
22655
22652
the equivalence class of top types.
@@ -22665,7 +22662,7 @@ \subsection{Functions Dealing with Extreme Types}
22665
22662
\end{itemize}
22666
22663
22667
22664
\noindent
22668
- The \Index{\IsObjectTypeName} predicate is true if{}f
22665
+ The \Index{\IsObjectTypeName} predicate is true if{}f
22669
22666
the argument is a subtype and a supertype of \code{Object}.
22670
22667
22671
22668
\begin{itemize}
@@ -23374,17 +23371,27 @@ \subsection{Type Type}
23374
23371
We define what it means for two types to be the same as follows:
23375
23372
Let $T_1$ and $T_2$ be types.
23376
23373
Let $U_j$ be the transitive alias expansion
23377
- (\ref{typedef}) of $T_j$, for $j \in 1 .. 2$.
23378
- We say that $T_1$ and $T_2$ are the \Index{same type}
23379
- if{}f \NormalizedTypeOf{$U_1$} and \NormalizedTypeOf{$U_2$}
23380
- (\ref{typeNormalization})
23381
- are syntactically equal,
23374
+ (\ref{typedef}) of $T_j$, for $j \in 1 .. 2$,
23375
+ and let $S_j$ be \NormalizedTypeOf{$U_j$}, for $j \in 1 .. 2$
23376
+ (\ref{typeNormalization}).
23377
+ We then say that $T_1$ and $T_2$ are the \Index{same type}
23378
+ if{}f $S_1$ and $S_2$ are syntactically equal,
23382
23379
up to equivalence of bound variables,
23383
23380
and up to replacement of identifiers or qualified identifiers
23384
23381
resolving to the same type declaration
23385
23382
(\commentary{%
23386
23383
e.g., \code{C} and \code{prefix.C} could resolve to
23387
23384
the same class declaration%
23385
+ }),
23386
+ and excluding the case where two identifiers or qualified identifiers
23387
+ occurring at corresponding positions in $S_1$ and $S_2$
23388
+ are syntactically identical,
23389
+ but resolve to different declarations
23390
+ (\commentary{%
23391
+ e.g., one occurrence of \code{C} could resolve to a
23392
+ class declaration imported from a library $L_1$,
23393
+ and another occurrence of \code{C} could resolve to a
23394
+ class declaration imported from a different library $L_2$%
23388
23395
}).
23389
23396
23390
23397
\LMHash{}%
@@ -23432,9 +23439,9 @@ \subsection{Type Type}
23432
23439
(\ref{constants})
23433
23440
evaluating to $o_1$ respectively $o_2$,
23434
23441
which are reified types reifying the types $T_1$ respecively $T_2$.
23435
- Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$
23442
+ Let $v_1$ and $v_2$ be fresh variables bound to $o_1$ respectively $o_2$.
23436
23443
We then have \code{identical($v_1$, $v_2$)} if{}f
23437
- \code{$T_1 $\,\,==\,\,$T_2 $}.
23444
+ \code{$v_1 $\,\,==\,\,$v_2 $}.
23438
23445
23439
23446
\commentary{%
23440
23447
In other words, constant reified types are canonicalized.
@@ -24054,22 +24061,22 @@ \subsubsection{Void Soundness}
24054
24061
\ABSTRACT{} \CLASS A<X> \{
24055
24062
final X x;
24056
24063
A(this.x);
24057
- Object foo(X x);
24064
+ Object? foo(X x);
24058
24065
\}
24059
24066
\\
24060
24067
\CLASS{} B<X> \EXTENDS{} A<X> \{
24061
24068
B(X x): super(x);
24062
- Object foo(Object x) => x;
24069
+ Object? foo(Object? x) => x;
24063
24070
\}
24064
24071
\\
24065
- Object f<X>(X x) => x;
24072
+ Object? f<X>(X x) => x;
24066
24073
\\
24067
24074
\VOID{} main() \{
24068
24075
\VOID x = 42;
24069
24076
print(f(x)); // \comment{(1)}
24070
24077
\\
24071
24078
A<\VOID{}> a = B<\VOID{}>(x);
24072
- A<Object> aObject = a;
24079
+ A<Object? > aObject = a;
24073
24080
print(aObject.x); // \comment{(2)}
24074
24081
print(a.foo(x)); // \comment{(3)}
24075
24082
\}
@@ -24086,25 +24093,25 @@ \subsubsection{Void Soundness}
24086
24093
which is or contains a type variable whose value could be \VOID,
24087
24094
so we are allowed to return \code{x} in the body of \code{f},
24088
24095
even though this means that we indirectly get access to the value
24089
- of an expression of type \VOID, under the static type \code{Object}.
24096
+ of an expression of type \VOID, under the static type \code{Object? }.
24090
24097
24091
24098
At (2), we indirectly obtain access to the value of
24092
24099
the variable \code{x} with type \VOID,
24093
24100
because we use an assignment to get access to the instance of \code{B}
24094
24101
which was created with type argument \VOID{} under the type
24095
- \code{A<Object>}.
24096
- Note that \code{A<Object>} and \code{A<\VOID{}>} are subtypes of each other,
24102
+ \code{A<Object? >}.
24103
+ Note that \code{A<Object? >} and \code{A<\VOID{}>} are subtypes of each other,
24097
24104
that is, they are equivalent according to the subtype rules,
24098
24105
so neither static nor dynamic type checks will fail.
24099
24106
24100
24107
At (3), we indirectly obtain access to the value of
24101
24108
the variable \code{x} with type \VOID{}
24102
- under the static type \code{Object},
24109
+ under the static type \code{Object? },
24103
24110
because the statically known method signature of \code{foo}
24104
24111
has parameter type \VOID,
24105
24112
but the actual implementation of \code{foo} which is invoked
24106
- is an override whose parameter type is \code{Object},
24107
- which is allowed because \code{Object} and \VOID{} are both top types.%
24113
+ is an override whose parameter type is \code{Object? },
24114
+ which is allowed because \code{Object? } and \VOID{} are both top types.%
24108
24115
}
24109
24116
24110
24117
\rationale{%
@@ -24125,7 +24132,7 @@ \subsubsection{Void Soundness}
24125
24132
from one variable or parameter to the next one, all with type \VOID,
24126
24133
explicitly, or as the value of a type parameter.
24127
24134
In particular, we could require that method overrides should
24128
- never override return type \code{Object} by return type \VOID,
24135
+ never override return type \code{Object? } by return type \VOID,
24129
24136
or parameter types in the opposite direction;
24130
24137
parameterized types with type argument \VOID{} could not be assigned
24131
24138
to variables where the corresponding type argument is anything other than
0 commit comments