@@ -22308,16 +22308,17 @@ \subsection{Function Types}
2230822308
2230922309\LMHash{}%
2231022310A function object is always an instance of some class $C$ that implements
22311- the class \FUNCTION{} (\ref{functionType}),
22312- and which has a method named \CALL,
22313- whose signature is the function type $C$ itself.
22311+ a function type $F$ which is a subtype of the class \FUNCTION{}
22312+ (\ref{functionType}).
22313+ The function object has a method named \CALL,
22314+ whose signature is said function type $F$.
2231422315\commentary{%
2231522316Consequently, all function types are subtypes of \FUNCTION{}
2231622317(\ref{subtypes}).%
2231722318}
2231822319
2231922320
22320- \subsection{Type \FUNCTION }
22321+ \subsection{Type Function }
2232122322\LMLabel{functionType}
2232222323
2232322324\LMHash{}%
@@ -22339,11 +22340,14 @@ \subsection{Type \FUNCTION}
2233922340\LMHash{}%
2234022341If a mixin application mixes \FUNCTION{} onto a superclass, it follows the
2234122342normal rules for mixin-application, but since the result of that mixin
22342- application is equivalent to a class with \code{implements Function }, and
22343+ application is equivalent to a class with \code{implements \FUNCTION }, and
2234322344that clause has no effect, the resulting class also does not
22344- implement \FUNCTION. \commentary{The \FUNCTION{} class declares no
22345- concrete instance members, so the mixin application creates a sub-class
22346- of the superclass with no new members and no new interfaces.}
22345+ implement \FUNCTION.
22346+ \commentary{%
22347+ The \FUNCTION{} class declares no concrete instance members,
22348+ so the mixin application creates a sub-class
22349+ of the superclass with no new members and no new interfaces.%
22350+ }
2234722351
2234822352\rationale{%
2234922353Since using \FUNCTION{} in these ways has no effect, it would be
@@ -22355,7 +22359,7 @@ \subsection{Type \FUNCTION}
2235522359}
2235622360
2235722361
22358- \subsection{Type \DYNAMIC }
22362+ \subsection{Type dynamic }
2235922363\LMLabel{typeDynamic}
2236022364
2236122365\LMHash{}%
@@ -22494,7 +22498,7 @@ \subsection{Type \DYNAMIC}
2249422498 \metavar{typeArguments} is a list of actual
2249522499 type arguments derived from \synt{typeArguments}, and
2249622500 \metavar{arguments} is an actual argument list derived from \synt{arguments}.
22497- It is a compile-time error if \id{} is the name of
22501+ It is a \Error{ compile-time error} if \id{} is the name of
2249822502 a non-generic method declared in \code{Object}.
2249922503 \commentary{%
2250022504 No generic methods are declared in \code{Object}.
@@ -22568,7 +22572,7 @@ \subsection{Type FutureOr}
2256822572That is, \code{FutureOr} is in a sense
2256922573the union of $T$ and the corresponding future type.
2257022574The last point guarantees that
22571- \code{FutureOr<$T$>} <: \code{Object},
22575+ \code{FutureOr<$T$>} <: \code{Object? },
2257222576and also that \code{FutureOr} is covariant in its type parameter,
2257322577just like class types:
2257422578if $S$ <: $T$ then \code{FutureOr<$S$>} <: \code{FutureOr<$T$>}.%
@@ -22577,7 +22581,7 @@ \subsection{Type FutureOr}
2257722581\LMHash{}%
2257822582If the type arguments passed to \code{FutureOr} would incur compile-time errors
2257922583if applied to a normal generic class with one type parameter,
22580- the same compile-time errors are issued for \code{FutureOr}.
22584+ the same \Error{ compile-time errors} are issued for \code{FutureOr}.
2258122585The name \code{FutureOr} as an expression
2258222586denotes a \code{Type} object representing the type \code{FutureOr<dynamic>}.
2258322587
@@ -22621,7 +22625,7 @@ \subsection{Type FutureOr}
2262122625\end{itemize}
2262222626
2262322627
22624- \subsection{Type Void }
22628+ \subsection{Type void }
2262522629\LMLabel{typeVoid}
2262622630
2262722631\LMHash{}%
@@ -22651,28 +22655,17 @@ \subsection{Type Void}
2265122655\commentary{%
2265222656The type \VOID{} is a top type
2265322657(\ref{superBoundedTypes}),
22654- so \VOID{} and \code{Object} are subtypes of each other
22658+ so \VOID{} and \code{Object? } are subtypes of each other
2265522659(\ref{subtypes}),
2265622660which also implies that any object can be
22657- the value of an expression of type \VOID.
22658- %
22659- Consequently, any instance of type \code{Type} which reifies the type \VOID{}
22660- must compare equal (according to the \lit{==} operator \ref{equality})
22661- to any instance of \code{Type} which reifies the type \code{Object}
22662- (\ref{dynamicTypeSystem}).
22663- It is not guaranteed that \code{identical(\VOID, Object)} evaluates to true.
22664- In fact, it is not recommended that implementations strive to achieve this,
22665- because it may be more important to ensure that diagnostic messages
22666- (including stack traces and dynamic error messages)
22667- preserve enough information to use the word `void' when referring to types
22668- which are specified as such in source code.%
22661+ the value of an expression of type \VOID.%
2266922662}
2267022663
2267122664\LMHash{}%
2267222665In support of the notion
2267322666that the value of an expression with static type \VOID{} should be discarded,
2267422667such objects can only be used in specific situations:
22675- The occurrence of an expression of type \VOID{} is a compile-time error
22668+ The occurrence of an expression of type \VOID{} is a \Error{ compile-time error}
2267622669unless it is permitted according to one of the following rules.
2267722670
2267822671\begin{itemize}
@@ -22702,6 +22695,7 @@ \subsection{Type Void}
2270222695 where it is not an error to have it.%
2270322696 }
2270422697\item
22698+ %% This relies on \IsMoreTopType{\VOID}{$T$} = \VOID.
2270522699 In a conditional expression \code{$e$\,?\,$e_1$\,:\,$e_2$},
2270622700 $e_1$ and $e_2$ may have type \VOID.
2270722701 \rationale{%
@@ -22711,20 +22705,13 @@ \subsection{Type Void}
2271122705 in some context where it is not an error to have it.%
2271222706 }
2271322707\item
22708+ %% This relies on \IsMoreTopType{\VOID}{$T$} = \VOID.
2271422709 In a null coalescing expression \code{$e_1$\,??\,$e_2$},
2271522710 $e_2$ may have type \VOID.
2271622711 \rationale{%
2271722712 The static type of the null coalescing expression is then \VOID,
2271822713 which in turn restricts where it can occur.%
2271922714 }
22720- \item
22721- In an expression of the form \code{\AWAIT\,\,$e$}, $e$ may have type \VOID.
22722- \rationale{%
22723- This rule was adopted because it was a substantial breaking change
22724- to turn this situation into an error
22725- at the time where the treatment of \VOID{} was changed.
22726- Tools may choose to give a hint in such cases.%
22727- }
2272822715\item
2272922716 \commentary{%
2273022717 In a return statement \code{\RETURN\,$e$;},
@@ -22792,13 +22779,13 @@ \subsection{Type Void}
2279222779Finally, we need to address situations involving implicit usage of
2279322780an object whose static type can be \VOID.
2279422781%
22795- It is a compile-time error for a for-in statement to have an iterator
22782+ It is a \Error{ compile-time error} for a for-in statement to have an iterator
2279622783expression of type $T$ such that \code{Iterator<\VOID{}>}
2279722784is the most specific instantiation of \code{Iterator}
2279822785that is a superinterface of $T$, unless the
2279922786iteration variable has type \VOID.
2280022787%
22801- It is a compile-time error for an asynchronous for-in statement
22788+ It is a \Error{ compile-time error} for an asynchronous for-in statement
2280222789to have a stream expression of type $T$
2280322790such that \code{Stream<\VOID{}>} is the most specific
2280422791instantiation of \code{Stream} that is a superinterface of $T$,
@@ -22809,7 +22796,7 @@ \subsection{Type Void}
2280922796}
2281022797
2281122798\begin{dartCode}
22812- \FOR{} (Object x in <\VOID>[]) \{\} // \comment{Error.}
22799+ \FOR{} (Object? x in <\VOID>[]) \{\} // \comment{Error.}
2281322800\AWAIT{} \FOR{} (int x \IN{} new Stream<\VOID{}>.empty()) \{\} // \comment{Error.}
2281422801\FOR{} (\VOID{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK.}
2281522802\FOR (\VAR{} x \IN{} <\VOID{}>[]) \{\ldots\} // \comment{OK, type of x inferred.}
@@ -22857,22 +22844,22 @@ \subsubsection{Void Soundness}
2285722844\ABSTRACT{} \CLASS A<X> \{
2285822845 final X x;
2285922846 A(this.x);
22860- Object foo(X x);
22847+ Object? foo(X x);
2286122848\}
2286222849\\
2286322850\CLASS{} B<X> \EXTENDS{} A<X> \{
2286422851 B(X x): super(x);
22865- Object foo(Object x) => x;
22852+ Object? foo(Object? x) => x;
2286622853\}
2286722854\\
22868- Object f<X>(X x) => x;
22855+ Object? f<X>(X x) => x;
2286922856\\
2287022857\VOID{} main() \{
2287122858 \VOID x = 42;
2287222859 print(f(x)); // \comment{(1)}
2287322860 \\
2287422861 A<\VOID{}> a = B<\VOID{}>(x);
22875- A<Object> aObject = a;
22862+ A<Object? > aObject = a;
2287622863 print(aObject.x); // \comment{(2)}
2287722864 print(a.foo(x)); // \comment{(3)}
2287822865\}
@@ -22889,25 +22876,25 @@ \subsubsection{Void Soundness}
2288922876which is or contains a type variable whose value could be \VOID,
2289022877so we are allowed to return \code{x} in the body of \code{f},
2289122878even though this means that we indirectly get access to the value
22892- of an expression of type \VOID, under the static type \code{Object}.
22879+ of an expression of type \VOID, under the static type \code{Object? }.
2289322880
2289422881At (2), we indirectly obtain access to the value of
2289522882the variable \code{x} with type \VOID,
2289622883because we use an assignment to get access to the instance of \code{B}
2289722884which was created with type argument \VOID{} under the type
22898- \code{A<Object>}.
22899- Note that \code{A<Object>} and \code{A<\VOID{}>} are subtypes of each other,
22885+ \code{A<Object? >}.
22886+ Note that \code{A<Object? >} and \code{A<\VOID{}>} are subtypes of each other,
2290022887that is, they are equivalent according to the subtype rules,
2290122888so neither static nor dynamic type checks will fail.
2290222889
2290322890At (3), we indirectly obtain access to the value of
2290422891the variable \code{x} with type \VOID{}
22905- under the static type \code{Object},
22892+ under the static type \code{Object? },
2290622893because the statically known method signature of \code{foo}
2290722894has parameter type \VOID,
2290822895but the actual implementation of \code{foo} which is invoked
22909- is an override whose parameter type is \code{Object},
22910- which is allowed because \code{Object} and \VOID{} are both top types.%
22896+ is an override whose parameter type is \code{Object? },
22897+ which is allowed because \code{Object? } and \VOID{} are both top types.%
2291122898}
2291222899
2291322900\rationale{%
@@ -22928,7 +22915,7 @@ \subsubsection{Void Soundness}
2292822915from one variable or parameter to the next one, all with type \VOID,
2292922916explicitly, or as the value of a type parameter.
2293022917In particular, we could require that method overrides should
22931- never override return type \code{Object} by return type \VOID,
22918+ never override return type \code{Object? } by return type \VOID,
2293222919or parameter types in the opposite direction;
2293322920parameterized types with type argument \VOID{} could not be assigned
2293422921to variables where the corresponding type argument is anything other than
@@ -22976,7 +22963,7 @@ \subsection{Parameterized Types}
2297622963Let $T$ be a parameterized type \code{$G$<$S_1, \ldots,\ S_n$>}.
2297722964
2297822965\LMHash{}%
22979- It is a compile-time error if $G$ is not a generic type,
22966+ It is a \Error{ compile-time error} if $G$ is not a generic type,
2298022967or $G$ is a generic type,
2298122968but the number of formal type parameters in the declaration of $G$ is not $n$.
2298222969Otherwise, let
@@ -22991,7 +22978,7 @@ \subsection{Parameterized Types}
2299122978or $T$ is not well-bounded (\ref{superBoundedTypes}).
2299222979
2299322980\LMHash{}%
22994- It is a compile-time error if $T$ is malbounded.
22981+ It is a \Error{ compile-time error} if $T$ is malbounded.
2299522982
2299622983\LMHash{}%
2299722984$T$ is evaluated as follows.
@@ -23015,7 +23002,8 @@ \subsection{Parameterized Types}
2301523002%% replaced by the bottom type (`Null`, for now) in locations of the member
2301623003%% type where it occurs contravariantly. For instance, `c.f` should have
2301723004%% static type `void Function(Null)` when `c` has static type `C<T>` for any
23018- %% `T`, and we have `class C<X> { void Function(X) f; }`.
23005+ %% `T`, and we have `class C<X> { void Function(X) f; }`. Cf. issue
23006+ %% https://github.com/dart-lang/language/issues/297.
2301923007
2302023008
2302123009\subsubsection{Actual Types}
@@ -23195,7 +23183,7 @@ \subsubsection{Reserved Words}
2319523183\LMHash{}%
2319623184A \Index{reserved word} can only be used in the syntactic positions
2319723185specified by the grammar.
23198- In particular, a compile-time error occurs if a reserved word is used
23186+ In particular, a \Error{ compile-time error} occurs if a reserved word is used
2319923187where an identifier is expected.
2320023188
2320123189\commentary{%
0 commit comments