f8995da6aa
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>
28 lines
738 B
Dart
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()`.
|
|
}
|