blob: 76e2fd885fb8ea3acc4bcd3e277d2f1cf1aaec96 [file] [log] [blame]
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// @assertion Any expression that appears within the initializer list of a
/// constant constructor must be a potentially constant expression, or a
/// compile-time error occurs.
///
/// A potentially constant expression is an expression E that would be a valid
/// constant expression if all formal parameters of E's immediately enclosing
/// constant constructor were treated as compile-time constants that were
/// guaranteed to evaluate to an integer, boolean or string value as required
/// by their immediately enclosing superexpression.
/// @description Checks that it is a compile-time error when a constant
/// constructor's initializer list contains an instance creation expression.
/// @author iefremov
class A {
final x;
const A() : x = new List.from([]);
// ^^^
// [analyzer] unspecified
// [cfe] unspecified
}
main() {
const A();
// ^
// [analyzer] unspecified
}