mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:37:12 +00:00
0b175ed534
Change-Id: Ic0597bf7ec69811ec822539ef5df1e24ef1b9884 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194560 Reviewed-by: Jake Macdonald <jakemac@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Commit-Queue: Kallen Tu <kallentu@google.com>
24 lines
748 B
Dart
24 lines
748 B
Dart
// Copyright (c) 2021, 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.
|
|
|
|
// Tests const constructors with a body are disabled without const functions.
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
const printString = "print";
|
|
const var1 = Simple(printString);
|
|
// ^
|
|
// [cfe] Cannot invoke a non-'const' constructor where a const expression is expected.
|
|
class Simple {
|
|
final String name;
|
|
|
|
const Simple(this.name) {
|
|
//^
|
|
// [cfe] A const constructor can't have a body.
|
|
// ^
|
|
// [analyzer] SYNTACTIC_ERROR.CONST_CONSTRUCTOR_WITH_BODY
|
|
assert(this.name == printString);
|
|
}
|
|
}
|