dart-sdk/tests/language_2/regress_31066_test.dart
Régis Crelier 61251c2c4e [VM] Ensure that the constant right-hand side of operator ?? is canonicalized (fixes #31066).
Add regression test.

Change-Id: I48f33b91b75f372e14ed5aa9185e79e105307573
Reviewed-on: https://dart-review.googlesource.com/16330
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2017-10-24 23:50:09 +00:00

23 lines
535 B
Dart

// Copyright (c) 2017, 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';
typedef Bar = int Function(int);
int defaultBar(int value) => value + 1;
class Foo {
final Bar bar;
const Foo._(Bar bar) : bar = bar ?? defaultBar;
const Foo.baz({Bar bar}) : this._(bar);
}
void main() {
final foo = const Foo.baz();
Expect.equals(2, foo.bar(1));
}