@@ -5454,42 +5454,93 @@ \subsection{Mixin Application}
54545454A mixin may be applied to a superclass, yielding a new class.
54555455
54565456\LMHash{}%
5457- Let $S$ be a class,
5458- $M$ be a mixin with \NoIndex{required superinterface}s $T_1$, \ldots, $T_n$,
5459- \NoIndex{combined superinterface} $M_S$,
5460- \NoIndex{implemented interfaces} $I_1$, \ldots, $I_k$ and
5461- \metavar{members} as \NoIndex{mixin member declarations},
5462- and let $N$ be a name.
5457+ \BlindDefineSymbol{S, S'}%
5458+ Let $S$ be a class, and let $S'$ be a parameterized type of the form
5459+ \code{$S$<$\cdots$>}.
5460+ \commentary{%
5461+ This includes the case where $S$ is non-generic and $S'$ is $S$.%
5462+ }
5463+
5464+ \LMHash{}%
5465+ \BlindDefineSymbol{M, \metavar{members}}%
5466+ Let $M$ be a mixin with member declarations \metavar{members}.
5467+ \BlindDefineSymbol{M', T_j}%
5468+ Let $M'$ be a parameterized type of the form
5469+ \code{$M$<$\cdots$>}
5470+ \commentary{(again including the case where $M'$ is $M$)}.
5471+ Let \List{T}{1}{n} be the required superinterfaces,
5472+ \BlindDefineSymbol{M_S, I_j}
5473+ $M_S$ the combined superinterface,
5474+ \List{I}{1}{k} the implemented interfaces,
5475+ all of $M$ and corresponding to $M'$.
54635476
54645477\LMHash{}%
5465- It is a compile-time error to apply $M$ to $S$ if $S$ does not implement,
5466- directly or indirectly, all of $T_1$, \ldots, $T_n$.
5478+ It is a compile-time error to apply $M'$ to $S'$
5479+ unless $S'$ implements each of \List{T}{1}{n}
5480+ (\ref{interfaceSuperinterfaces}).
54675481It is a compile-time error if any of \metavar{members} contains a
5468- super-invocation of a member $m$ \commentary{(for example \code{super.foo},
5469- \code{super + 2}, or \code{super[1] = 2})}, and $S$ does not have a concrete
5470- implementation of $m$ which is a valid override of the member $m$ in
5471- the interface $M_S$. \rationale{We treat super-invocations in mixins as
5472- interface invocations on the combined superinterface, so we require the
5473- superclass of a mixin application to have valid implementations of those
5474- interface members that are actually super-invoked.}
5475-
5476- \LMHash{}%
5477- The mixin application of $M$ to $S$ with name $N$ introduces a new
5478- class, $C$, with name $N$, superclass $S$,
5479- implemented interface $M$
5480- and \metavar{members} as instance members.
5482+ super-invocation of a member $m$
5483+ \commentary{%
5484+ (for example \code{super.foo}, \code{super + 2}, or \code{super[1] = 2})%
5485+ },
5486+ and $S'$ does not have a concrete implementation of $m$ which is
5487+ a valid override of the member $m$ in the interface $M_S$.
5488+ \rationale{%
5489+ We treat super-invocations in mixins as interface invocations on
5490+ the combined superinterface,
5491+ so we require the superclass of a mixin application to have
5492+ valid implementations of those interface members
5493+ that are actually super-invoked.%
5494+ }
5495+
5496+ \LMHash{}%
5497+ Let \DefineSymbol{L_C} be the library containing the mixin application.
5498+ \commentary{%
5499+ That is, the library containing the clause \code{$S$ \WITH{} $M$}
5500+ or the clause \code{$S_0$ \WITH{} $M_1$, \ldots,\ $M_k$, $M$} giving rise
5501+ to the mixin application.%
5502+ }
5503+ Let \DefineSymbol{L_M} be the library containing the declaration of $M$.
5504+
5505+ \LMHash{}%
5506+ Assume that $S$ has a member $m_S$ which is accessible to $L_M$,
5507+ that $m_S$ has the name $n$ which is private
5508+ (\commentary{so $m_S$ is declared in $L_M$}),
5509+ and that $M$ declares a member $m_M$ which is also named $n$
5510+ \commentary{(note that $m_M$ is also declared in $L_M$)}.
5511+ In this case a compile-time error occurs.
5512+
5513+ \commentary{%
5514+ In this situation $m_M$ would override $m_S$ if $M'$ is applied to $S'$,
5515+ and this happens because of the mixin application which is outside of $L_M$,
5516+ even though $m_M$ and $m_S$ are private.
5517+ One of the unfortunate consequences of this situanion is that
5518+ invocations of $m_S$ which could otherwise be statically resolved
5519+ (in cases where it is otherwise guaranteed that $m_S$ is not overridden)
5520+ must now be invoked using late binding.
5521+ Because of this, and because of some other complications,
5522+ this kind of ``private overriding from outside'' is prevented by making it
5523+ a compile-time error to perform the mixin application.%
5524+ }
5525+
5526+ \LMHash{}%
5527+ Let \DefineSymbol{N} be a name.
5528+ The
5529+ \Index{mixin application}
5530+ of $M'$ to $S'$ with name $N$
5531+ introduces a new class, \DefineSymbol{C},
5532+ with name $N$, superclass $S'$, implemented interface $M'$,
5533+ and instance members
5534+ which are the concrete declarations in \metavar{members},
5535+ substituting type variables of $M$ corresponding to $M'$.
54815536The class $C$ has no static members.
54825537If $S$ declares any generative constructors, then the application
54835538introduces generative constructors on $C$ as follows:
54845539
54855540\LMHash{}%
5486- Let $L_C$ be the library containing the mixin application.
5487- \commentary{That is, the library containing the clause \code{$S$ \WITH{} $M$}
5488- or the clause \code{$S_0$ \WITH{} $M_1$, \ldots,\ $M_k$, $M$} giving rise
5489- to the mixin application.}
5490-
5491- Let $S_N$ be the name of $S$.
5541+ Let \DefineSymbol{S_N} be the name of $S$.
54925542
5543+ \LMHash{}%
54935544For each generative constructor of the form
54945545\code{$S_q$($T_{1}$ $a_{1}$, $\ldots$, $T_{k}$ $a_{k}$)}
54955546of $S$ that is accessible to $L_C$, $C$ has
0 commit comments