blob: 22b5b499b59f66e4ac8d9169ecfe0d537ca3b15a [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 We allow tearing off named constructors.
///
/// If [C] denotes a class declaration and [C.name] is the name of a constructor
/// of that class, we allow you to tear off that constructors as:
///
/// C.name, or
/// C<typeArgs>.name
///
/// just as you can currently invoke the constructor as [C.name(args)], or
/// [C<typeArgs>.name(args)].
///
/// @description Checks that tearing off named constructor with type arguments
/// is allowed for a generic class.
/// @author iarkh@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs
import "../../Utils/expect.dart";
class C<T> {
bool called = false;
C.constr(int i) {
Expect.isTrue(T == int);
called = true;
}
}
main() {
var v = C<int>.constr;
C c = v(1);
Expect.isTrue(c.called);
}