Skip to content

Commit cbf51e1

Browse files
committed
Assignability, generics
1 parent cc52528 commit cbf51e1

File tree

2 files changed

+13
-49
lines changed

2 files changed

+13
-49
lines changed

specification/dart.sty

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -356,12 +356,6 @@
356356
\newcommand{\Supertype}[3]{\ensuremath{{#1}\vdash{#2}\,:>\,{#3}}}
357357
\newcommand{\SupertypeStd}[2]{\Supertype{\Gamma}{#1}{#2}}
358358

359-
% Judgment expressing that an assignability relation exists.
360-
\newcommand{\AssignableRelationSymbol}{\ensuremath{\Longleftrightarrow}}
361-
\newcommand{\Assignable}[3]{%
362-
\ensuremath{{#1}\vdash{#2}\,\AssignableRelationSymbol\,{#3}}}
363-
\newcommand{\AssignableStd}[2]{\Assignable{\Gamma}{#1}{#2}}
364-
365359
% Semantic function delivering the superinterfaces of a class.
366360
\newcommand{\Superinterfaces}[1]{\ensuremath{\metavar{Superinterfaces}({#1})}}
367361
\newcommand{\Superinterface}[2]{{#1}\in\Superinterfaces{#2}}

specification/dartLangSpec.tex

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7158,7 +7158,7 @@ \section{Generics}
71587158
\LMHash{}%
71597159
A type parameter $T$ may be suffixed with an \EXTENDS{} clause
71607160
that specifies the \Index{upper bound} for $T$.
7161-
If no \EXTENDS{} clause is present, the upper bound is \code{Object}.
7161+
If no \EXTENDS{} clause is present, the upper bound is \code{Object?}.
71627162
It is a
71637163
\Error{compile-time error} if a type parameter is a supertype of its upper bound
71647164
when that upper bound is itself a type variable.
@@ -21886,27 +21886,19 @@ \subsubsection{Additional Subtyping Concepts}
2188621886
\LMHash{}%
2188721887
A type $T$
2188821888
\Index{may be assigned}
21889-
to a type $S$ in an environment $\Gamma$,
21890-
written \AssignableStd{S}{T},
21891-
if{}f either \SubtypeStd{S}{T} or \SubtypeStd{T}{S}.
21892-
In this case we say that the types $S$ and $T$ are
21893-
\Index{assignable}.
21889+
to a type $S$ in an environment $\Gamma$
21890+
if{}f $T$ is \DYNAMIC, or \SubtypeStd{T}{S}.
21891+
In this case we also say that the type $T$ is \Index{assignable} to $S$.
2189421892

2189521893
\rationale{%
21896-
This rule may surprise readers accustomed to conventional typechecking.
21897-
The intent of the \AssignableRelationSymbol{} relation
21898-
is not to ensure that an assignment is guaranteed to succeed dynamically.
21899-
Instead, it aims to only flag assignments
21900-
that are almost certain to be erroneous,
21901-
without precluding assignments that may work.
21902-
21903-
For example, assigning an object of static type \code{Object}
21904-
to a variable with static type \code{String},
21905-
while not guaranteed to be correct,
21906-
might be fine if the run-time value happens to be a string.
21907-
21908-
A static analyzer or compiler
21909-
may support more strict static checks as an option.%
21894+
The use of the type \DYNAMIC{} is intended to shift type checks from
21895+
compile time to run time,
21896+
thus allowing operations that are not statically safe,
21897+
but which may succeed or fail at run time.
21898+
This treatment of \DYNAMIC{} ensures that
21899+
expressions of type \DYNAMIC{} are treated
21900+
as if the compiler would implicitly insert a downcast whenever needed,
21901+
in order to make the program type correct.%
2191021902
}
2191121903

2191221904

@@ -23840,32 +23832,10 @@ \subsubsection{Const type variable elimination}
2384023832
\}
2384123833
\end{dartCode}
2384223834

23843-
\subsubsection{Extension method resolution}
23835+
\subsubsection{Combined member signatures}
2384423836

2384523837
!!!TODO!!!
2384623838

23847-
For the purposes of extension method resolution, there is no special treatment
23848-
of nullable types with respect to what members are considered accessible. That
23849-
is, the only members of a nullable type that are considered accessible
23850-
(and hence which take precedence over extensions) are the members on \code{Object}.
23851-
23852-
For the purposes of extension method resolution, the type \code{Never} is considered
23853-
to implement all members, and hence no extension may apply to an expression of
23854-
type \code{Never}.
23855-
23856-
\subsubsection{Assignability}
23857-
23858-
The definition of assignability is changed as follows.
23859-
23860-
A type $T$ is \Index{assignable} to a type $S$ if $T$ is \DYNAMIC, or if $T$ is a
23861-
subtype of $S$.
23862-
23863-
\subsubsection{Generics}
23864-
23865-
The default bound of generic type parameters is treated as \code{Object?}.
23866-
23867-
\subsubsection{Combined member signatures}
23868-
2386923839
This section, line 4241
2387023840
in the language specification defines the notion of a _combined member
2387123841
signature_. In Dart before null-safety it is based on the textually first

0 commit comments

Comments
 (0)