Skip to content

Commit fc9b0ec

Browse files
committed
Assignability, generics
1 parent 4935821 commit fc9b0ec

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
@@ -357,12 +357,6 @@
357357
\newcommand{\Supertype}[3]{\ensuremath{{#1}\vdash{#2}\,:>\,{#3}}}
358358
\newcommand{\SupertypeStd}[2]{\Supertype{\Gamma}{#1}{#2}}
359359

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

specification/dartLangSpec.tex

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7197,7 +7197,7 @@ \section{Generics}
71977197
\LMHash{}%
71987198
A type parameter $T$ may be suffixed with an \EXTENDS{} clause
71997199
that specifies the \Index{upper bound} for $T$.
7200-
If no \EXTENDS{} clause is present, the upper bound is \code{Object}.
7200+
If no \EXTENDS{} clause is present, the upper bound is \code{Object?}.
72017201
It is a
72027202
\Error{compile-time error} if a type parameter is a supertype of its upper bound
72037203
when that upper bound is itself a type variable.
@@ -22014,27 +22014,19 @@ \subsubsection{Additional Subtyping Concepts}
2201422014
\LMHash{}%
2201522015
A type $T$
2201622016
\Index{may be assigned}
22017-
to a type $S$ in an environment $\Gamma$,
22018-
written \AssignableStd{S}{T},
22019-
if{}f either \SubtypeStd{S}{T} or \SubtypeStd{T}{S}.
22020-
In this case we say that the types $S$ and $T$ are
22021-
\Index{assignable}.
22017+
to a type $S$ in an environment $\Gamma$
22018+
if{}f $T$ is \DYNAMIC, or \SubtypeStd{T}{S}.
22019+
In this case we also say that the type $T$ is \Index{assignable} to $S$.
2202222020

2202322021
\rationale{%
22024-
This rule may surprise readers accustomed to conventional typechecking.
22025-
The intent of the \AssignableRelationSymbol{} relation
22026-
is not to ensure that an assignment is guaranteed to succeed dynamically.
22027-
Instead, it aims to only flag assignments
22028-
that are almost certain to be erroneous,
22029-
without precluding assignments that may work.
22030-
22031-
For example, assigning an object of static type \code{Object}
22032-
to a variable with static type \code{String},
22033-
while not guaranteed to be correct,
22034-
might be fine if the run-time value happens to be a string.
22035-
22036-
A static analyzer or compiler
22037-
may support more strict static checks as an option.%
22022+
The use of the type \DYNAMIC{} is intended to shift type checks from
22023+
compile time to run time,
22024+
thus allowing operations that are not statically safe,
22025+
but which may succeed or fail at run time.
22026+
This treatment of \DYNAMIC{} ensures that
22027+
expressions of type \DYNAMIC{} are treated
22028+
as if the compiler would implicitly insert a downcast whenever needed,
22029+
in order to make the program type correct.%
2203822030
}
2203922031

2204022032

@@ -23968,32 +23960,10 @@ \subsubsection{Const type variable elimination}
2396823960
\}
2396923961
\end{dartCode}
2397023962

23971-
\subsubsection{Extension method resolution}
23963+
\subsubsection{Combined member signatures}
2397223964

2397323965
!!!TODO!!!
2397423966

23975-
For the purposes of extension method resolution, there is no special treatment
23976-
of nullable types with respect to what members are considered accessible. That
23977-
is, the only members of a nullable type that are considered accessible
23978-
(and hence which take precedence over extensions) are the members on \code{Object}.
23979-
23980-
For the purposes of extension method resolution, the type \code{Never} is considered
23981-
to implement all members, and hence no extension may apply to an expression of
23982-
type \code{Never}.
23983-
23984-
\subsubsection{Assignability}
23985-
23986-
The definition of assignability is changed as follows.
23987-
23988-
A type $T$ is \Index{assignable} to a type $S$ if $T$ is \DYNAMIC, or if $T$ is a
23989-
subtype of $S$.
23990-
23991-
\subsubsection{Generics}
23992-
23993-
The default bound of generic type parameters is treated as \code{Object?}.
23994-
23995-
\subsubsection{Combined member signatures}
23996-
2399723967
This section, line 4241
2399823968
in the language specification defines the notion of a _combined member
2399923969
signature_. In Dart before null-safety it is based on the textually first

0 commit comments

Comments
 (0)