Skip to content

Commit c565d4e

Browse files
lrhncommit-bot@chromium.org
authored andcommitted
Make the specification not mention LinkedHashSet.
It has implementation consequences to refer to classes that are not declared in dart:core, and it increases the library/spec interaction surface. This change removes all references to `LinkedHashSet` from the spec. It changess the rule for when a `{}` is a set to be context type is a subtype of `FutureOr^\inf(Iterable<Object>)` and not a subtupe of `FutureOr^\inf(Map<Object,Object>)`. That should *work* for * `Iterable<X>` * `Set<X>` * `LinkedHashSet<X>` * `HashSet<X>` * `FutureOr<Set<X>>` (with likely exect-type issues as usual). Change-Id: I3074da27b36093075c8c83e9672bf2fdec135c1c Reviewed-on: https://dart-review.googlesource.com/c/87972 Commit-Queue: Lasse R.H. Nielsen <[email protected]> Reviewed-by: Erik Ernst <[email protected]>
1 parent 9f866c8 commit c565d4e

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

docs/language/dart.sty

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696

9797
% Auxiliary functions.
9898
\newcommand{\flatten}[1]{\ensuremath{\mbox{\it flatten}({#1})}}
99+
\newcommand{\basetype}[1]{\ensuremath{\mbox{\it basetype}({#1})}}
99100
\newcommand{\overrides}[1]{\ensuremath{\mbox{\it overrides}({#1})}}
100101
\newcommand{\inherited}[1]{\ensuremath{\mbox{\it inherited}({#1})}}
101102

docs/language/dartLangSpec.tex

+22-13
Original file line numberDiff line numberDiff line change
@@ -6507,17 +6507,17 @@ \subsection{Maps}
65076507
\end{grammar}
65086508

65096509
\LMHash{}%
6510-
A \synt{setOrMapLiteral} is either set literal (\ref {sets}) or a map literal,
6510+
A \synt{setOrMapLiteral} $e$ is either set literal (\ref {sets}) or a map literal,
65116511
determined by the type parameters or static context type.
65126512
If the literal expression has exactly one type argument,
6513-
then it is a set literal.
6514-
If it has two type arguments, then it is a map literal.
6515-
If it has three or more type arguments, it is a compile-time error.
6516-
If it has \emph{no} type arguments,
6517-
then if \code{LinkedHashSet<Null>} is assignable to the
6518-
static context type of the literal,
6519-
and \code{LinkedHashMap<Null, Null>} is not,
6520-
it is set literal,
6513+
then $e$ is a set literal.
6514+
If $e$ has two type arguments, then it is a map literal.
6515+
If $e$ has three or more type arguments, it is a compile-time error.
6516+
If $e$ has \emph{no} type arguments,
6517+
then let $S$ be the static context type of the literal.
6518+
If $\basetype{S}$ (\ref{typeFutureOr}) is a subtype of \code{Iterable<Object>}
6519+
and $\basetype{S}$ is not a subtype of \code{Map<Object, Object>},
6520+
then $e$ is set literal,
65216521
and otherwise it is a map literal.
65226522
A map literal derived from \synt{setOrMapLiteral}
65236523
is treated the same way as one derived from \synt{mapLiteral},
@@ -6723,10 +6723,10 @@ \subsection{Sets}
67236723
\item
67246724
For each $i \in 1 .. n$ in numeric order,
67256725
the expression $e_i$ is evaluated producing object $v_i$.
6726-
\item A fresh instance (\ref{generativeConstructors}) $s$
6727-
of the built-in class \code{LinkedHashSet<$E$>}, is allocated.
6728-
\item
6729-
The operator \code{add} is invoked on $s$ with argument $v_i$ for each $i \in 1 .. n$ in numerical order.
6726+
\item A fresh object (\ref{generativeConstructors}) $s$
6727+
implementing the built-in class \code{Set<$E$>}, is created.
6728+
\item The set $s$ is made to have the values $v_1, \ldots{} , v_n$ as elements,
6729+
iterated in numerical order.
67306730
\item
67316731
The result of the evaluation is $s$.
67326732
\end{itemize}
@@ -13943,6 +13943,15 @@ \subsection{Type FutureOr}
1394313943
only allow invocations of members inherited from \code{Object}.
1394413944
}
1394513945

13946+
\LMHash{}%
13947+
We define the auxiliary function
13948+
\IndexCustom{\basetype{T}}{basetype(t)@\emph{basetype}$(T)$}
13949+
as follows:
13950+
13951+
\begin{itemize}
13952+
\item If $T$ is \code{FutureOr<$S$>} for some $S$ then $\basetype{T} = \basetype{S}$.
13953+
\item Otherwise $\basetype{T} = T$.
13954+
\end{itemize}
1394613955

1394713956
\subsection{Type Void}
1394813957
\LMLabel{typeVoid}

0 commit comments

Comments
 (0)