blob: 4e3bf9dc3e73814daec5e41aeacee623e42dd850 [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 If [C] denotes a class, an expression of [C] by itself already
/// has a meaning, it evaluates to a [Type] object representing the class, so it
/// cannot also denote the unnamed constructor.
/// @description Checks that unnamed constructor tear off can be used in a
/// factory constructor. Test generic classes
/// @author
// SharedOptions=--enable-experiment=constructor-tearoffs
import "../../Utils/expect.dart";
class C<T> {
T t;
factory C.f1(T t) = C<T>.new;
factory C.f2(T t) = D<T>;
factory C.f3(T t) = D<T>.new;
class D<T> extends C<T> {
D(T t) :;
main() {
Expect.isFalse(C<int>.f1(42) is D<int>);
Expect.isTrue(C<int>.f2(42) is D<int>);
Expect.isTrue(C<String>.f3("Lily was here") is D<String>);