blob: 3aae91d9fcc6b1153da6c7a5e1dcce2a37093dca [file] [log] [blame]
* Copyright (c) 2019, 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 Calling a redirecting factory constructor k causes the
* constructor k' denoted by type (respectively, type.identifier) to be called
* with the actual arguments passed to k, and returns the result of k' as the
* result of k. The resulting constructor call is governed by the same rules
* as an instance creation expression using new.
* @description Checks that a call to redirecting factory constructor indeed
* results in a call to referenced constructor with the same actual arguments.
* Test type aliases
* @author
// SharedOptions=--enable-experiment=nonfunction-type-aliases
import "../../../../Utils/expect.dart";
class F {
factory F(x) = CAlias;
factory, [y]) =;
factory, {z}) =;
typedef FAlias = F;
class C implements FAlias {
var x, y, z;
C(this.x);, [this.y]);, {this.z});
typedef CAlias = C;
main() {
C f = new F(1);
Expect.isTrue(f is C);
Expect.equals(1, f.x);
f = new, 2);
Expect.isTrue(f is C);
Expect.equals(1, f.x);
Expect.equals(2, f.y);
f = new, z:3);
Expect.equals(1, f.x);
Expect.equals(3, f.z);