Skip to content

Commit 0a25c3a

Browse files
authored
Specify dynamic Object member invocations (#3902)
This PR modifies the language specification by adding references to section 'Type dynamic' in two locations where this is needed. The reference is needed because 'Type dynamic' specifies the static type of members of `Object` which is used with receivers of type dynamic. This reference is needed in section 'Ordinary Invocation' and section 'Getter access and method extraction', where expressions of the form `dynamicExpression.toString()` respectively `dynamicExpression.toString` are specified.
1 parent 893b109 commit 0a25c3a

File tree

1 file changed

+59
-8
lines changed

1 file changed

+59
-8
lines changed

specification/dartLangSpec.tex

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
% version of the language which will actually be specified by the next stable
4242
% release of this document.
4343
%
44+
% Jun 2024
45+
% - Add missing references to section 'Type dynamic' at the points where the
46+
% static analysis of Object member invocations is specified.
47+
%
4448
% Feb 2024
4549
% - Correct the rule about deriving a future type from a type (which is used
4650
% by `flatten`).
@@ -14213,13 +14217,25 @@ \subsubsection{Ordinary Invocation}
1421314217

1421414218
\LMHash{}%
1421514219
Let $T$ be the static type of $e$.
14216-
It is a compile-time error if $T$ does not have an accessible
14220+
14221+
\LMHash{}%
14222+
If $T$ is \DYNAMIC{} bounded
14223+
(\ref{bindingActualsToFormals})
14224+
and $m$ is one of
14225+
\code{hashCode}, \code{noSuchMethod}, \code{runtimeType}, or \code{toString}
14226+
then we say that $i$ is a
14227+
\IndexCustom{dynamic \code{Object} member invocation}{
14228+
dynamic Object member invocation},
14229+
whose static analysis is specified separately below.
14230+
14231+
\LMHash{}%
14232+
Otherwise, it is a compile-time error if $T$ does not have an accessible
1421714233
(\ref{privacy})
1421814234
instance member named $m$, unless either:
14235+
1421914236
\begin{itemize}
1422014237
\item
14221-
$T$ is \DYNAMIC{} bounded
14222-
(\ref{bindingActualsToFormals});
14238+
$T$ is \DYNAMIC{} bounded;
1422314239
in this case no further static checks are performed on $i$
1422414240
(\commentary{apart from separate static checks on subterms like arguments})
1422514241
and the static type of $i$ is \DYNAMIC.
@@ -14252,7 +14268,22 @@ \subsubsection{Ordinary Invocation}
1425214268
}).
1425314269

1425414270
\LMHash{}%
14255-
Otherwise \code{$T$.$m$} denotes an instance member.
14271+
If $i$ is a dynamic \code{Object} member invocation
14272+
(\ref{ordinaryInvocation})
14273+
then the static type of the member is specified in
14274+
Section~\ref{typeDynamic}.
14275+
In this case, if $m$ is \code{hashCode} or \code{runtimeType}
14276+
then let $F$ be the return type of said getter;
14277+
if $m$ is \code{noSuchMethod} or \code{toString}
14278+
then let $F$ be the type of said method.
14279+
14280+
\commentary{%
14281+
Note that it is always a compile-time error if $m$
14282+
is \code{hashCode} or \code{runtimeType}.%
14283+
}
14284+
14285+
\LMHash{}%
14286+
Otherwise, \code{$T$.$m$} denotes an instance member.
1425614287
Let $L$ be the library that contains $i$.
1425714288
Let $d$ be the result of method lookup for $m$ in $T$ with respect to $L$,
1425814289
and if the method lookup succeeded then let $F$ be the static type of $d$.
@@ -14840,13 +14871,33 @@ \subsubsection{Getter Access and Method Extraction}
1484014871

1484114872
\LMHash{}%
1484214873
Let $T$ be the static type of $e$.
14843-
It is a compile-time error if $T$ does not have a method or getter named \id{}
14844-
unless $T$ is \DYNAMIC{} bounded
14845-
(\ref{bindingActualsToFormals}),
14846-
or $T$ is \FUNCTION{} bounded and \id{} is \CALL.
14874+
14875+
\LMHash{}%
14876+
If $T$ is \DYNAMIC{} bounded
14877+
(\ref{bindingActualsToFormals})
14878+
and $m$ is one of
14879+
\code{hashCode}, \code{noSuchMethod}, \code{runtimeType}, or \code{toString}
14880+
then we say that $i$ is a
14881+
\IndexCustom{dynamic \code{Object} property extraction}{
14882+
dynamic Object property extraction},
14883+
whose static analysis is specified separately below.
14884+
14885+
\LMHash{}%
14886+
Otherwise, it is a compile-time error if $T$ does not have
14887+
a method or getter named \id{}
14888+
unless $T$ is \DYNAMIC{} bounded,
14889+
or $T$ is \FUNCTION{} bounded
14890+
(\ref{bindingActualsToFormals})
14891+
and \id{} is \CALL.
1484714892
The static type of $i$ is:
1484814893

1484914894
\begin{itemize}
14895+
\item The return type as specified in Section~\ref{typeDynamic}
14896+
if $i$ is a dynamic \code{Object} property extraction
14897+
and \id{} is \code{hashCode} or \code{runtimeType}.
14898+
\item The static type as specified in Section~\ref{typeDynamic}
14899+
if $i$ is a dynamic \code{Object} property extraction
14900+
and \id{} is \code{noSuchMethod} or \code{toString}.
1485014901
\item The declared return type of \code{$T$.\id},
1485114902
if $T$ has an accessible instance getter named \id.
1485214903
\item The function type of the method signature \code{$T$.\id},

0 commit comments

Comments
 (0)