You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
}
2275
2291
2276
2292
%Discuss External Constructors in ne subsubsection here
0 commit comments