blob: 2518881c9d32d407a57a03abcdd2e43a6e68515e [file] [log] [blame]
// 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.
/// @assertion A named constructor tear-off expression of one of the forms above
/// evaluates to a function value which could be created by tearing off a
/// corresponding constructor function, which would be a static function defined
/// on the class denoted by [C], with a fresh name here represented by adding
/// [$tearoff]:
///
/// static C name$tearoff<typeParams>(params) => C<typeArgs>.name(args);
///
/// @description Checks constructor tear-off expression for generic class.
/// @author iarkh@unipro.ru
import "../../Utils/expect.dart";
class C<T> {
static int called = 0;
C() {}
C.constr(expected) {
Expect.equals(expected, T);
called++;
}
}
main() {
Expect.isTrue(C.constr@tearoff is C Function<dynamic>(dynamic));
C c = C.constr@tearoff(dynamic);
Expect.equals(1, C.called);
C c1 = C<int>.constr@tearoff(int);
Expect.equals(2, C.called);
}