You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/language/dartLangSpec.tex
+64-23Lines changed: 64 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,8 @@
40
40
% abstractly, to eliminate certain diagnostic messages.
41
41
% - Add generic functions and methods to the language.
42
42
% - Don't cause warning if a non-system library import shadows a system library.
43
+
% - Update mixin application forwarding constructors to correctly handle
44
+
% optional parameters and const constructors.
43
45
%
44
46
% 1.15
45
47
% - Change how language specification describes control flow.
@@ -2215,7 +2217,7 @@ \subsection{Superclasses}
2215
2217
\LMLabel{superclasses}
2216
2218
2217
2219
\LMHash{}
2218
-
The superclass of a class $C$ that has a with clause \code{\WITH{} $M_1, \ldots,\ M_k$} and an extends clause \code{\EXTENDS{} S} is the application of mixin (\ref{mixins}) $M_k* \cdots * M_1$ to S.
2220
+
The superclass $S^\prime$of a class $C$ that has a with clause \code{\WITH{} $M_1, \ldots,\ M_k$} and an extends clause \code{\EXTENDS{} $S$} is the application of mixin composition (\ref{mixins}) $M_k* \cdots * M_1$ to $S$. The name $S^\prime$ is a fresh identifier.
2219
2221
If no \WITH{} clause is specified then the \EXTENDS{} clause of a class $C$ specifies its superclass.
2220
2222
If no \EXTENDS{} clause is specified, then either:
2221
2223
\begin{itemize}
@@ -2554,7 +2556,8 @@ \section{Mixins}
2554
2556
A mixin is always derived from an existing class declaration.
2555
2557
2556
2558
\LMHash{}
2557
-
It is a compile-time error if a declared or derived mixin explicitly declares a constructor which is not a factory constructor.
2559
+
It is a compile-time error to derive a mixin from a class which explicitly declares a generative constructor.
2560
+
It is a compile-time error to derive a mixin from a class which has a superclass other than \code{Object}.
A mixin may be applied to a superclass, yielding a new class.
2572
-
Mixin application occurs when a mixin is mixed into a class declaration via its \WITH{} clause.
2573
-
The mixin application may be used to extend a class per section (\ref{classes}); alternately, a class may be defined as a mixin application as described in this section.
2575
+
Mixin application occurs when one or more mixins are mixed into a class declaration via its \WITH{} clause.
2576
+
The mixin application may be used to extend a class per section (\ref{classes}); alternatively, a class may be defined as a mixin application as described in this section.
2574
2577
It is a compile-time error if the \WITH{} clause of a mixin application $C$ includes a type variable (\ref{generics}), a type alias (\ref{typedef}), an enumerated type (\ref{enums}), a malformed type, or a deferred type (\ref{staticTypes}).
A mixin application of the form \code{$S$\WITH{} $M$;} defines a class $C$ with superclass $S$.
2588
+
A mixin application of the form \code{$S$\WITH{} $M$;} for the name $N$defines a class $C$ with superclass $S$ and name $N$.
2586
2589
2587
2590
\LMHash{}
2588
-
A mixin application of the form \code{$S$\WITH{} $M_1, \ldots,\ M_k$;} defines a class $C$ whose superclass is the application of the mixin composition (\ref{mixinComposition}) $M_{k-1} * \ldots * M_1$ to $S$.
2591
+
A mixin application of the form \code{$S$\WITH{} $M_1,\ \ldots, M_k$;} for the name $N$ defines a class $C$ whose superclass is the application of the mixin composition (\ref{mixinComposition}) $M_{k-1} * \ldots * M_1$ to $S$ of a name that is a fresh identifer, and whose name is $N$.
2592
+
\rationale{The name of the resulting class is necessary because it is part of the names of the introduced constructors.}
2589
2593
2590
2594
\LMHash{}
2591
2595
In both cases above, $C$ declares the same instance members as $M$ (respectively, $M_k$).
2592
-
If any of the instance variables of $M$ (respectively, $M_k$) have initializers, they are executed in the scope of $M$ (respectively, $M_k$) to initialize the corresponding instance variables of $C$.
2596
+
If any of the instance variables of $M$ (respectively, $M_k$) have initializers,
2597
+
they are executed in the instance scope of $M$ (respectively, $M_k$)
2598
+
to initialize the corresponding instance variables of $C$.
2593
2599
2594
2600
\LMHash{}
2595
-
Let $L_M$ be the library in which $M$ is declared.
2596
-
For each generative constructor named
2597
-
$q_i(T_{i1}\ a_{i1}, \ldots,\ T_{ik_i}\ a_{ik_i}), i \in1 .. n$
2598
-
of $S$ that is accessible to $L_M$,
2599
-
$C$ has an implicitly declared constructor named
2600
-
$q'_i = [C/S]q_i$ of the form
2601
+
Let $L_C$ be the library containing the mixin application.
2602
+
\commentary{That is, the library containing the clause \code{$S$\WITH{} $M$}
2603
+
or the clause \code{$S_0$\WITH{} $M_1$, \ldots,\ $M_k$, $M$}.}
Let $N_C$ be the name of the mixin application class $C$,
2606
+
let $S$ be the superclass of $C$, and let $S_N$ be the name of $S$.
2603
2607
2604
-
%super.id
2608
+
For each generative constructor of the form \code{$S_q$($T_{1}$$a_{1}$, $\ldots$, $T_{k}$$a_{k}$)} of $S$ that is accessible to $L_C$, $C$ has an implicitly declared constructor of the form
\noindent{}where $C_q$ is obtained from $S_q$ by replacing occurrences of $S_N$,
2613
+
which denote the superclass, by $N_C$, and $\SUPER_q$ is obtained from $S_q$ by
2614
+
replacing occurrences of $S_N$ which denote the superclass by \SUPER{}}.
2615
+
If $S_q$ is a generative const constructor, and $M$ does not declare any
2616
+
fields, $C_q$ is also a const constructor.
2617
+
2618
+
\LMHash{}
2619
+
For each generative constructor of the form \code{$S_q$($T_{1}$$a_{1}$, \ldots , $T_{k}$$a_{k}$, [$T_{k+1}$$a_{k+1}$ = $d_1$, \ldots , $T_{k+p}$$a_{k+p}$ = $d_p$])} of $S$ that is accessible to $L_C$, $C$ has an implicitly declared constructor of the form
\noindent{}where $C_q$ is obtained from $S_q$ by replacing occurrences of $S_N$,
2625
+
which denote the superclass, by $N_C$,
2626
+
$\SUPER_q$ is obtained from $S_q$ by replacing occurrences of $S_N$
2627
+
which denote the superclass by \SUPER{},
2628
+
and $d'_i$, $i \in1..p$, is a compile-time constant expression evaluating
2629
+
to the same value as $d_i$.
2630
+
If $S_q$ is a generative const constructor, and $M$ does not declare any
2631
+
fields, $C_q$ is also a const constructor.
2632
+
2633
+
\LMHash{}
2634
+
For each generative constructor of the form \code{$S_q$($T_{1}$$a_{1}$, \ldots , $T_{k}$$a_{k}$, \{$T_{k+1}$$a_{k+1}$ = $d_1$, \ldots , $T_{k+n}$$a_{k+n}$ = $d_n$\})} of $S$ that is accessible to $L_C$, $C$ has an implicitly declared constructor of the form
The effect of a class definition of the form \code{\CLASS{} $C$ = $M$; } or the form \code{\CLASS{} $C$<$T_1, \ldots,\ T_n$> = $M$; } in library $L$ is to introduce the name $C$ into the scope of $L$, bound to the class (\ref{classes}) defined by the mixin application $M$.
2665
+
The effect of a class definition of the form \code{\CLASS{} $C$ = $M$; } or the form \code{\CLASS{} $C<T_1, \ldots,\ T_n>$ = $M$; } in library $L$ is to introduce the name $C$ into the scope of $L$, bound to the class (\ref{classes}) defined by the mixin application $M$ for the name $C$.
2625
2666
The name of the class is also set to $C$.
2626
2667
If{}f the class is prefixed by the built-in identifier \ABSTRACT{}, the class being defined is an abstract class.
Note that any subset of $M_1$, $M_2$ and $S$ may or may not be generic.
2679
-
For any non-generic declaration, the corresponding type parameters may be elided, and if no type parameters remain in the derived declarations $Id_1$ and/or $Id_2$ then the those declarations need not be generic either.
2720
+
For any non-generic declaration, the corresponding type parameters may be elided, and if no type parameters remain in the derived declarations $C$ and/or $Id_2$ then the those declarations need not be generic either.
0 commit comments