Files
sdk/tests/language/const_global_test.dart
T
asgerf@google.com bd3255ed6a dart2dart: Support for all constants in new backend.
Adds support for:
- Type literals
- By-value reference to top-level or static function
- Const constructor invocation inside const literal list or map

Nested const expressions are linearized to LetPrims, and we rely on the dart_tree to inline all primitives (since non-const variable references may not occur in a const expression).

There are still a bunch of constants that we support but don't actually treat as constants. Reference to top-level constants are still treated as a getter invocations, for instance.

We bail out on local constant declarations since they must either be inlined at multiple places or we must generate a constant declaration for them.

BUG=
R=kmillikin@google.com, sigurdm@google.com

Review URL: https://codereview.chromium.org//348053002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@37585 260f80e4-7a28-3924-810f-c04153c831b5
2014-06-23 08:46:08 +00:00

19 lines
435 B
Dart

// 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.
import "package:expect/expect.dart";
const a = 1;
main() {
Expect.equals(1, a);
Expect.equals(1, const A(a).a);
Expect.equals(1, const [const A(a)][0].a);
}
class A {
final a;
const A(this.a);
}