Skip to content

Commit 563d587

Browse files
committed
More typeType fixes
1 parent e6fb219 commit 563d587

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
@@ -5149,9 +5149,11 @@ \subsection{Superinterfaces}
51495149
is not a class building type
51505150
(\ref{classBuildingTypes}).
51515151
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$.
51555157

51565158
\rationale{%
51575159
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}
79777979
Meta-variables
79787980
(\ref{metaVariables})
79797981
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}).
79897985

79907986
The intuition behind the situation where a type raw-depends on another type is
79917987
that we need to compute any missing type arguments for the latter
@@ -11478,9 +11474,10 @@ \subsubsection{Sets}
1147811474
$o_2$ with contents $o_{21}, \ldots, o_{2n}$ and actual type argument $t_2$
1147911475
be the result of evaluating them.
1148011476
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$.
1148411481

1148511482
\commentary{%
1148611483
In other words, constant set literals are canonicalized if they have
@@ -15227,9 +15224,9 @@ \subsubsection{Instance Method Closurization}
1522715224

1522815225
\LMHash{}%
1522915226
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
1523315230
the corresponding parameter declaration in $D$.
1523415231
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
1523515232

@@ -15381,9 +15378,9 @@ \subsubsection{Super Closurization}
1538115378

1538215379
\LMHash{}%
1538315380
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
1538715384
the corresponding parameter declaration in $D$.
1538815385
If that parameter declaration has no type annotation then $T_j$ is \DYNAMIC.
1538915386

@@ -15642,8 +15639,7 @@ \subsubsection{Generic Method Instantiation}
1564215639
Consider the situation where the program evaluates
1564315640
two invocations of this method with the same receiver $o$,
1564415641
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,
1564715643
and assume that the invocations returned
1564815644
the instances $o_1$ respectively $o_2$.
1564915645
%
@@ -22007,7 +22003,8 @@ \subsubsection{Subtype Rules}
2200722003
\IndexCustom{instantiating}{instantiation!subtype rule}
2200822004
it, that is, by consistently replacing
2200922005
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}).
2201122008

2201222009
\commentary{%
2201322010
In general, this means that two or more occurrences of
@@ -22509,7 +22506,7 @@ \subsection{Type Nullability}
2250922506
so it cannot be non-nullable.
2251022507

2251122508
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,
2251322510
and $X$ is also potentially non-nullable, but not non-nullable.%
2251422511
}
2251522512

@@ -22649,7 +22646,7 @@ \subsection{Functions Dealing with Extreme Types}
2264922646
\TopMergeTypeName{} of the first two,
2265022647
and then recursively taking \TopMergeTypeName{} of the rest.
2265122648
\commentary{The ordering of the arguments makes no difference.}
22652-
22649+
2265322650
\LMHash{}%
2265422651
The \Index{\IsTopTypeName} predicate is true for any type which is in
2265522652
the equivalence class of top types.
@@ -22665,7 +22662,7 @@ \subsection{Functions Dealing with Extreme Types}
2266522662
\end{itemize}
2266622663

2266722664
\noindent
22668-
The \Index{\IsObjectTypeName} predicate is true if{}f
22665+
The \Index{\IsObjectTypeName} predicate is true if{}f
2266922666
the argument is a subtype and a supertype of \code{Object}.
2267022667

2267122668
\begin{itemize}
@@ -23374,17 +23371,27 @@ \subsection{Type Type}
2337423371
We define what it means for two types to be the same as follows:
2337523372
Let $T_1$ and $T_2$ be types.
2337623373
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,
2338223379
up to equivalence of bound variables,
2338323380
and up to replacement of identifiers or qualified identifiers
2338423381
resolving to the same type declaration
2338523382
(\commentary{%
2338623383
e.g., \code{C} and \code{prefix.C} could resolve to
2338723384
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$%
2338823395
}).
2338923396

2339023397
\LMHash{}%
@@ -23432,9 +23439,9 @@ \subsection{Type Type}
2343223439
(\ref{constants})
2343323440
evaluating to $o_1$ respectively $o_2$,
2343423441
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$.
2343623443
We then have \code{identical($v_1$, $v_2$)} if{}f
23437-
\code{$T_1$\,\,==\,\,$T_2$}.
23444+
\code{$v_1$\,\,==\,\,$v_2$}.
2343823445

2343923446
\commentary{%
2344023447
In other words, constant reified types are canonicalized.
@@ -24054,22 +24061,22 @@ \subsubsection{Void Soundness}
2405424061
\ABSTRACT{} \CLASS A<X> \{
2405524062
final X x;
2405624063
A(this.x);
24057-
Object foo(X x);
24064+
Object? foo(X x);
2405824065
\}
2405924066
\\
2406024067
\CLASS{} B<X> \EXTENDS{} A<X> \{
2406124068
B(X x): super(x);
24062-
Object foo(Object x) => x;
24069+
Object? foo(Object? x) => x;
2406324070
\}
2406424071
\\
24065-
Object f<X>(X x) => x;
24072+
Object? f<X>(X x) => x;
2406624073
\\
2406724074
\VOID{} main() \{
2406824075
\VOID x = 42;
2406924076
print(f(x)); // \comment{(1)}
2407024077
\\
2407124078
A<\VOID{}> a = B<\VOID{}>(x);
24072-
A<Object> aObject = a;
24079+
A<Object?> aObject = a;
2407324080
print(aObject.x); // \comment{(2)}
2407424081
print(a.foo(x)); // \comment{(3)}
2407524082
\}
@@ -24086,25 +24093,25 @@ \subsubsection{Void Soundness}
2408624093
which is or contains a type variable whose value could be \VOID,
2408724094
so we are allowed to return \code{x} in the body of \code{f},
2408824095
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?}.
2409024097

2409124098
At (2), we indirectly obtain access to the value of
2409224099
the variable \code{x} with type \VOID,
2409324100
because we use an assignment to get access to the instance of \code{B}
2409424101
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,
2409724104
that is, they are equivalent according to the subtype rules,
2409824105
so neither static nor dynamic type checks will fail.
2409924106

2410024107
At (3), we indirectly obtain access to the value of
2410124108
the variable \code{x} with type \VOID{}
24102-
under the static type \code{Object},
24109+
under the static type \code{Object?},
2410324110
because the statically known method signature of \code{foo}
2410424111
has parameter type \VOID,
2410524112
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.%
2410824115
}
2410924116

2411024117
\rationale{%
@@ -24125,7 +24132,7 @@ \subsubsection{Void Soundness}
2412524132
from one variable or parameter to the next one, all with type \VOID,
2412624133
explicitly, or as the value of a type parameter.
2412724134
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,
2412924136
or parameter types in the opposite direction;
2413024137
parameterized types with type argument \VOID{} could not be assigned
2413124138
to variables where the corresponding type argument is anything other than

0 commit comments

Comments
 (0)