Files
sdk/pkg/front_end/testcases/magic_const.dart
T
Dmitry Stefantsov f8995da6aa Report a compile-time error on magic const
When inferring const or new for expressions that aren't required to be const,
Fasta always choses new. That's not correct, and this is a short-term work
around to avoid introducing a breaking change in the future. The plan is to
implement this feature correctly, but that will require more time than we have
right now.

Originally submitted by ahe@google.com.  Added: status file fixes.

Change-Id: I2d70bd2488de6b69fcd5546c1f4654dfbbb30b7f
Reviewed-on: https://dart-review.googlesource.com/46340
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2018-03-13 19:07:12 +00:00

28 lines
738 B
Dart

// 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.
/// Test that we produce a compile-time error when magic constness would
/// otherwise apply.
// TODO(ahe): Update this test when we implement magic constness correctly.
class Constant {
const Constant();
}
class NotConstant {}
foo({a: Constant(), b: Constant(), c: []}) {}
test() {
const NotConstant();
Constant();
const x = Constant();
bool.fromEnvironment("fisk");
const b = bool.fromEnvironment("fisk");
}
main() {
// Don't invoke [test] as it throws a compile-time due to `const NotConstant()`.
}