mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:27:39 +00:00
Adjusted end of 10.6 about constant object expressions
Change-Id: Ia6890d6620ed8cff060a30fa90f6cd05fbcc2057 Reviewed-on: https://dart-review.googlesource.com/70621 Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
parent
3af2f793ac
commit
1a2532ce31
|
@ -2271,7 +2271,23 @@ This is precluded by the following rule, combined with the rules for evaluating
|
|||
}
|
||||
|
||||
\LMHash{}
|
||||
When invoked from a constant object expression, a constant constructor must throw an exception if any of its actual parameters is a value that would prevent one of the potentially constant expressions within it from being a valid compile-time constant.
|
||||
When a constant constructor $k$ is invoked from a constant object expression,
|
||||
it is a compile-time error if
|
||||
the invocation of $k$ at run time would throw an exception,
|
||||
and it is a compile-time error if
|
||||
substitution of the actual arguments for the formal parameters
|
||||
yields an initializing expression $e$ in the initializer list of $k$
|
||||
which is not a constant expression.
|
||||
|
||||
\commentary{
|
||||
For instance, if $e$ is \code{a.length}
|
||||
where \code{a} is a formal argument of $k$ with type \DYNAMIC{},
|
||||
$e$ is potentially constant and can be used in the initializer list of $k$.
|
||||
It is an error to invoke $k$ with an argument of type \code{C}
|
||||
if \code{C} is a class different from \code{String},
|
||||
even if \code{C} has a \code{length} getter,
|
||||
and that same expression would evaluate without errors at run time.
|
||||
}
|
||||
|
||||
%Discuss External Constructors in ne subsubsection here
|
||||
|
||||
|
|
Loading…
Reference in a new issue