Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

/// @assertion It is a compile-time error if:
/// ...
/// - The resulting constructor is not valid (has a redirecting initializer and
/// other initializers, multiple super initializers, etc).
/// - The resulting constructor is not valid (it has a redirection as well as
/// some initializer list elements, or it has multiple `super` initializers,
/// etc).
///
/// @description Checks that it is a compile-time error if the resulting
/// constructor has a redirecting initializer and other initializers.
/// constructor has a redirecting initializer and initializer list elements.
/// @author [email protected]

// SharedOptions=--enable-experiment=macros
Expand All @@ -18,7 +19,7 @@ part 'augmenting_constructors_A06_t01_lib.dart';
class C {
int x;
C(this.x);
C.foo(): this(0);
C.foo() : this(0);
//^^^^^
// [analyzer] unspecified
// [cfe] unspecified
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@

/// @assertion It is a compile-time error if:
/// ...
/// - The resulting constructor is not valid (has a redirecting initializer and
/// other initializers, multiple super initializers, etc).
/// - The resulting constructor is not valid (it has a redirection as well as
/// some initializer list elements, or it has multiple `super` initializers,
/// etc).
///
/// @description Checks that it is a compile-time error if the resulting
/// constructor has a redirecting initializer and other initializers.
/// constructor has a redirecting initializer and initializer list elements.
/// @author [email protected]

// SharedOptions=--enable-experiment=macros

part of 'augmenting_constructors_A06_t01.dart';

augment class C {
augment C.foo(): x = 1;
augment C.foo() : x = 1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2024, 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 It is a compile-time error if:
/// ...
/// - The resulting constructor is not valid (it has a redirection as well as
/// some initializer list elements, or it has multiple super initializers,
/// etc).
///
/// @description Checks that it is a compile-time error if the resulting
/// constructor has multiple super initializers.
/// @author [email protected]

// SharedOptions=--enable-experiment=macros

part 'augmenting_constructors_A06_t02_lib.dart';

class A {
int x;
A(this.x);
}

class C extends A {
C() : super(0);
//^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2024, 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 It is a compile-time error if:
/// ...
/// - The resulting constructor is not valid (it has a redirection as well as
/// some initializer list elements, or it has multiple super initializers,
/// etc).
///
/// @description Checks that it is a compile-time error if the resulting
/// constructor has multiple super initializers.
/// @author [email protected]

// SharedOptions=--enable-experiment=macros

part of 'augmenting_constructors_A06_t02.dart';

augment class C {
augment C() : super(1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// BSD-style license that can be found in the LICENSE file.

/// @assertion A non-redirecting generative constructor marked `augment` may:
/// - Add or replace the body of the augmented constructor with a new body.
/// - If the augmenting constructor has an explicit block body, then that body
/// replaces any existing constructor body.
/// ...
/// - If the augmenting constructor has an explicit block body, then that body
/// replaces any existing constructor body.
///
/// @description Checks that if the augmenting constructor has an explicit block
/// body, then that body replaces any existing constructor body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// BSD-style license that can be found in the LICENSE file.

/// @assertion A non-redirecting generative constructor marked `augment` may:
/// - Add or replace the body of the augmented constructor with a new body.
/// - If the augmenting constructor has an explicit block body, then that body
/// replaces any existing constructor body.
/// ...
/// - If the augmenting constructor has an explicit block body, then that body
/// replaces any existing constructor body.
///
/// @description Checks that if the augmenting constructor has an explicit block
/// body, then that body replaces any existing constructor body.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

/// @assertion A non-redirecting generative constructor marked `augment` may:
/// - Add or replace the body of the augmented constructor with a new body.
/// - If the augmenting constructor has an explicit block body, then that body
/// replaces any existing constructor body.
///
/// @description Checks that an augmenting constructor may add a body to an
/// augmented constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

/// @assertion A non-redirecting generative constructor marked `augment` may:
/// - Add or replace the body of the augmented constructor with a new body.
/// - If the augmenting constructor has an explicit block body, then that body
/// replaces any existing constructor body.
///
/// @description Checks that an augmenting constructor may add a body to an
/// augmented constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

/// @assertion A non-redirecting generative constructor marked `augment` may:
/// - Add or replace the body of the augmented constructor with a new body.
/// - If the augmenting constructor has an explicit block body, then that body
/// replaces any existing constructor body.
///
/// @description Checks that it is a compile-time error to augment a default
/// unnamed constructor (that doesn't exist during augmentation).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

/// @assertion A non-redirecting generative constructor marked `augment` may:
/// - Add or replace the body of the augmented constructor with a new body.
/// - If the augmenting constructor has an explicit block body, then that body
/// replaces any existing constructor body.
///
/// @description Checks that it is a compile-time error to augment a default
/// unnamed constructor (that doesn't exist during augmentation).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

/// @assertion A non-redirecting factory constructor marked `augment` works in
/// the same way as a normal function augmentation.
///
/// If it has a body, it replaces the body of the augmented constructor
/// (if present), and it may invoke the augmented body by calling
/// `augmented(arguments)`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

/// @assertion A redirecting generative constructor marked `augment` adds its
/// redirecting initializer to the augmented constructors initializer list.
/// redirection to the augmented constructor.
///
/// This converts it into a redirecting generative constructor, removing the
/// potentially non-redirecting property of the constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

/// @assertion A redirecting generative constructor marked `augment` adds its
/// redirecting initializer to the augmented constructors initializer list.
/// redirection to the augmented constructor.
///
/// This converts it into a redirecting generative constructor, removing the
/// potentially non-redirecting property of the constructor.
Expand All @@ -18,6 +18,6 @@
part of 'augmenting_constructors_A17_t01.dart';

augment class C {
augment C.foo(int x, {int y}): this(x, y);
augment C.bar(int x, {required int y}): this.foo(x, y: y);
augment C.foo(int x, {int y}) : this(x, y);
augment C.bar(int x, {required int y}) : this.foo(x, y: y);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

/// @assertion A redirecting generative constructor marked `augment` adds its
/// redirecting initializer to the augmented constructors initializer list.
/// redirection to the augmented constructor.
///
/// This converts it into a redirecting generative constructor, removing the
/// potentially non-redirecting property of the constructor.
Expand All @@ -20,8 +20,8 @@ part 'augmenting_constructors_A17_t02_lib.dart';
class C {
int x;
C(this.x);
C.foo(int x): this(x + 1);
C.bar(int x): this(x + 1);
C.foo(int x) : this(x + 1);
C.bar(int x) : this(x + 1);
}

main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

/// @assertion A redirecting generative constructor marked `augment` adds its
/// redirecting initializer to the augmented constructors initializer list.
/// redirection to the augmented constructor.
///
/// This converts it into a redirecting generative constructor, removing the
/// potentially non-redirecting property of the constructor.
Expand All @@ -17,5 +17,5 @@
part of 'augmenting_constructors_A17_t02.dart';

augment class C {
augment C.bar(int x): this.foo(x + 1);
augment C.bar(int x) : this.foo(x + 1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
/// @assertion Redirecting generative constructors
/// ...
/// It is a compile-time error if:
/// - The augmented constructor has any initializers or a body.
/// - The augmented constructor has an initializer list or a body, or it has a
/// redirection.
///
/// @description Checks that it is a compile-time error to declare an augmenting
/// redirecting generative constructor if the augmented constructor has
Expand All @@ -23,6 +24,21 @@ class C {
C.bar({required this.y});
}

enum E {
e0(1, 2), e1.foo(3, y: 4), e2.bar(5, y: 6);
final int x, y;
const E(this.x, [this.y = 0]);
const E.foo(this.x, {this.y = 0});
const E.bar(this.x, {required this.y});
}

extension type ET(int x) {
ET.foo(this.x);
ET.bar({required this.x});
}

main() {
print(C);
print(E);
print(ET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
/// @assertion Redirecting generative constructors
/// ...
/// It is a compile-time error if:
/// - The augmented constructor has any initializers or a body.
/// - The augmented constructor has an initializer list or a body, or it has a
/// redirection.
///
/// @description Checks that it is a compile-time error to declare an augmenting
/// redirecting generative constructor if the augmented constructor has
Expand All @@ -17,12 +18,35 @@
part of 'augmenting_constructors_A18_t01.dart';

augment class C {
augment C.foo(this.x, {this.y}): this(x);
augment C.foo(this.x, {this.y}) : this(x);
// ^
// [analyzer] unspecified
// [cfe] unspecified
augment C.bar({required this.y}): this.foo(0);
augment C.bar({required this.y}) : this.foo(0);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E {
augment e0;
augment const E.foo(this.x, {this.y}) : this(x);
// ^
// [analyzer] unspecified
// [cfe] unspecified
augment const E.bar(this.x, {required this.y}) : this.foo(0);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET {
augment ET.foo(this.x) : this(0);
// ^
// [analyzer] unspecified
// [cfe] unspecified
augment ET.bar({required this.x}) : this.new(1);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}
Loading