mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
b5d4d26abe
Change-Id: Ifd24678c0ac191c5cc6f1d60443ab96f56cbba7d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192400 Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Reviewed-by: Jake Macdonald <jakemac@google.com> Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Kallen Tu <kallentu@google.com>
35 lines
842 B
Dart
35 lines
842 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 factories with const functions.
|
|
|
|
// SharedOptions=--enable-experiment=const-functions
|
|
|
|
import "package:expect/expect.dart";
|
|
|
|
const printConst = MessageType.parse("print");
|
|
|
|
class MessageType {
|
|
static const print = MessageType._('print');
|
|
|
|
static const skip = MessageType._('skip');
|
|
|
|
final String name;
|
|
|
|
const factory MessageType.parse(String name) {
|
|
//^^^^^
|
|
// [analyzer] SYNTACTIC_ERROR.CONST_FACTORY
|
|
if (name == 'print') {
|
|
return MessageType.print;
|
|
}
|
|
return MessageType.skip;
|
|
}
|
|
|
|
const MessageType._(this.name);
|
|
}
|
|
|
|
void main() {
|
|
Expect.equals(printConst, MessageType.print);
|
|
}
|