blob: 88cd97f6294b77480077beccd8c59099d8ca0e92 [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 The constant-ness, identity and equality of the torn-off
/// constructor functions behave exactly the same as if they were tear-offs of
/// the corresponding static function. This means that a non-generic class
/// constructor always tears off to the same function value, as does an
/// uninstantiated tear off of a generic class constructor.
///
/// @description Checks equality of generic tear-offs of different constructors
/// but with the same signature
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs
import "../../Utils/expect.dart";
class C<T> {
T i, j;
C.name1(this.i, this.j) {}
C.name2(this.i, this.j);
C(this.i, this.j) {}
}
main() {
const v1 = C.name1;
const v2 = C.name1;
Expect.equals(v1, v2);
const CheckIdentical(v1, v2);
var v4 = C.name2;
var v5 = C.name2;
Expect.equals(v4, v5);
Expect.identical(v4, v5);
const v7 = C.new;
const v8 = C.new;
Expect.equals(v7, v8);
const CheckIdentical(v7, v8);
Expect.notEquals(v1, v4);
Expect.notEquals(v2, v7);
Expect.notEquals(v5, v8);
}