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,32 +4,69 @@

/// @assertion It is a compile-time error if:
/// ...
/// - The augmenting constructor parameters specify any default values.
/// - More than one declaration in the augmentation chain specifies a default
/// value for the same optional parameter. This is an error even in the case
/// where all of them are identical.
///
/// @description Checks that it is a compile-time error if the augmenting
/// constructor parameters specify any default values.
/// @description Checks that it is a compile-time error when both the augmenting
/// constructor parameters and the introductory declaration specify default
/// values.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

part 'augmenting_constructors_A02_t01_lib.dart';
// SharedOptions=--enable-experiment=augmentations

class C {
C([int x = 0]);
C.c1({int x = 0});
}

augment class C {
augment C([int x = 0]);
// ^
// [analyzer] unspecified
// [cfe] unspecified

augment C.c1({int x = 0});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
e0(0);
e0, e1.c1();
const E([int x = 0]);
const E.c1({int x = 0});
}

augment enum E {
augment const E([int x = 0]);
// ^
// [analyzer] unspecified
// [cfe] unspecified

augment const E.c1({int x = 0});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET(int id) {
ET.c1(this.id, [int x = 0]);
ET.c2(this.id, {int x = 0});
}

augment extension type ET {
augment ET.c1(this.id, [int x = 0]);
// ^
// [analyzer] unspecified
// [cfe] unspecified

augment ET.c2(this.id, {int x = 0});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// 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:
/// ...
/// - More than one declaration in the augmentation chain specifies a default
/// value for the same optional parameter. This is an error even in the case
/// where all of them are identical.
///
/// @description Checks that it is a compile-time error when more than one
/// augmenting constructor declaration specify default values.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=augmentations

class C {
C([int x]);
C.c1({int x});
}

augment class C {
augment C([int x = 0]);
augment C.c1({int x = 0});
}

augment class C {
augment C([int x = 0]);
// ^
// [analyzer] unspecified
// [cfe] unspecified

augment C.c1({int x = 0});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
e0, e1.c1();
const E([int x]);
const E.c1({int x});
}

augment enum E {
augment const E([int x = 0]);
augment const E.c1({int x = 0});
}

augment enum E {
augment const E([int x = 0]);
// ^
// [analyzer] unspecified
// [cfe] unspecified

augment const E.c1({int x = 0});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET(int id) {
ET.c1(this.id, [int x]);
ET.c2(this.id, {int x});
}

augment extension type ET {
augment ET.c1(this.id, [int x = 0]);
augment ET.c2(this.id, {int x = 0});
}

augment extension type ET {
augment ET.c1(this.id, [int x = 0]);
// ^
// [analyzer] unspecified
// [cfe] unspecified

augment ET.c2(this.id, {int x = 0});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
print(ET);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// 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:
/// ...
/// - More than one declaration in the augmentation chain specifies a default
/// value for the same optional parameter. This is an error even in the case
/// where all of them are identical.
///
/// @description Checks that it is not an error if an augmenting constructor
/// specifies default values for optional parameters.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=augmentations

import '../../Utils/expect.dart';

class C {
int x;
C([int x]);
C.c1({int x});
}

augment class C {
augment C([int x = 1]) : x = x;
augment C.c1({int x = 2}) : x = x;
}

enum E {
e0, e1.c1();

final int x;
const E([int x]);
const E.c1({int x});
}

augment enum E {
augment const E([int x = 1]) : x = x;
augment const E.c1({int x = 2}) : x = x;
}

String log = "";

extension type ET(int id) {
ET.c1(this.id, [int x]);
ET.c2(this.id, {int x});
}

augment extension type ET {
augment ET.c1(this.id, [int x = 1]) : assert(() {
log = "$x";
return true;
}());
augment ET.c2(this.id, {int x = 2}) assert(() {
log = "$x";
return true;
}());
}

main() {
Expect.equals(1, C().x);
Expect.equals(2, C.c1().x);
Expect.equals(1, E.e0.x);
Expect.equals(2, E.e1.x);
ET.c1(0);
if (assertStatementsEnabled()) {
Expect.equals("1", log);
}
ET.c2(0);
if (assertStatementsEnabled()) {
Expect.equals("2", log);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@
/// constructor is `const` and the augmenting constructor is not.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

part 'augmenting_constructors_A03_t01_lib.dart';
// SharedOptions=--enable-experiment=augmentations

class C {
const C();
}

augment class C {
augment C();
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET(int id) {
const ET.foo(this.id);
}

augment extension type ET {
augment ET.foo(this.id);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(ET);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,30 @@
/// constructor is `const` and the introductory constructor is not.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

part 'augmenting_constructors_A03_t02_lib.dart';
// SharedOptions=--enable-experiment=augmentations

class C {
C();
}

augment class C {
augment const C();
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET(int id) {
ET.foo(this.id);
}

augment extension type ET {
augment const ET.foo(this.id);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(ET);
Expand Down
Loading
Loading