blob: 77e412761aee9d38e9dfd9e9c1f8e0bc9eba9662 [file] [log] [blame]
// Copyright (c) 2018, 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.
library fasta.constant_context;
enum ConstantContext {
/// Not in a constant context.
///
/// This means that `Object()` and `[]` are equivalent to `new Object()` and
/// `[]` respectively. `new Object()` is **not** a compile-time error.
///
/// TODO(ahe): Update the above specification and corresponding
/// implementation because `Object()` is a compile-time constant. See [magic
/// const](
/// ../../../../../../docs/language/informal/docs/language/informal/implicit-creation.md
/// ).
none,
/// In a context where constant expressions are required, and `const` may be
/// inferred.
///
/// This means that `Object()` and `[]` are equivalent to `const Object()` and
/// `const []` respectively. `new Object()` is a compile-time error.
inferred,
/// In a context where constant expressions are required, but `const` is not
/// inferred. This includes default values of optional parameters and
/// initializing expressions on fields in classes with a `const` constructor.
required,
}