Skip to content

Commit 1a2532c

Browse files
committed
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 <[email protected]>
1 parent 3af2f79 commit 1a2532c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/language/dartLangSpec.tex

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2271,7 +2271,23 @@ \subsubsection{Constant Constructors}
22712271
}
22722272

22732273
\LMHash{}
2274-
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.
2274+
When a constant constructor $k$ is invoked from a constant object expression,
2275+
it is a compile-time error if
2276+
the invocation of $k$ at run time would throw an exception,
2277+
and it is a compile-time error if
2278+
substitution of the actual arguments for the formal parameters
2279+
yields an initializing expression $e$ in the initializer list of $k$
2280+
which is not a constant expression.
2281+
2282+
\commentary{
2283+
For instance, if $e$ is \code{a.length}
2284+
where \code{a} is a formal argument of $k$ with type \DYNAMIC{},
2285+
$e$ is potentially constant and can be used in the initializer list of $k$.
2286+
It is an error to invoke $k$ with an argument of type \code{C}
2287+
if \code{C} is a class different from \code{String},
2288+
even if \code{C} has a \code{length} getter,
2289+
and that same expression would evaluate without errors at run time.
2290+
}
22752291

22762292
%Discuss External Constructors in ne subsubsection here
22772293

0 commit comments

Comments
 (0)