mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 22:21:18 +00:00
e2cc730067
It looks like some of the tests in this block were already migrated, but I re-migrated them and made a few tweaks that I think make them better 2.0 tests. Change-Id: I6d9058a53408f046d7db34f2244eeeb2c5eda625 Reviewed-on: https://dart-review.googlesource.com/13620 Reviewed-by: Ben Konyi <bkonyi@google.com>
26 lines
881 B
Dart
26 lines
881 B
Dart
// Copyright (c) 2015, 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.
|
|
|
|
// If a constant constructor contains an initializer, or an initializing
|
|
// formal, for a final field which itself has an initializer at its
|
|
// declaration, then a compile-time error should be reported regardless of
|
|
// whether the constructor is called with "const" or "new".
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
class C {
|
|
final x = 1;
|
|
const C() : x = 2; //# 01: compile-time error
|
|
const C() : x = 2; //# 02: compile-time error
|
|
const C(this.x); //# 03: compile-time error
|
|
const C(this.x); //# 04: compile-time error
|
|
}
|
|
|
|
main() {
|
|
const C(); //# 01: continued
|
|
new C(); //# 02: continued
|
|
const C(2); //# 03: continued
|
|
new C(2); //# 04: continued
|
|
}
|