dart-sdk/tests/language_2/const_cast1_test.dart
Sigmund Cherem 0284fdab6b dart2js: allow as expressions in constants
The CFE doesn't allow them explicitly yet, but implicit casts do show up by the
time we see them in dart2js.

Closes https://github.com/dart-lang/sdk/issues/32773

Change-Id: Idb566625ce7c8edc74a4eea0109491bd72357051
Reviewed-on: https://dart-review.googlesource.com/49801
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2018-04-06 00:46:30 +00:00

17 lines
485 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.
/// Implicit casts in constants are supported and treated as compile-time errors
/// if they are not valid.
class A {
final int n;
const A(dynamic input) : n = input;
}
main() {
print(const A(2)); //# 01: ok
print(const A('2')); //# 02: compile-time error
}