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
@@ -0,0 +1,197 @@
// 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 The exact result of an `augmented` expression depends on what is
/// being augmented, but it generally follows the same rules as any normal
/// identifier:
/// - Augmenting getters: Within an augmenting getter `augmented` invokes the
/// augmented getter and evaluates to its return value. If augmenting a
/// variable with a getter, this will invoke the implicitly induced getter
/// from the augmented variable declaration.
///
/// @description Checks that it is a compile-time error if in an augmenting
/// scope an augmenting getter has a metadata named `augmented`.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

class augmented {
const augmented();
}

@augmented()
String get topLevelGetter => "Original";

@augmented()
augment String get topLevelGetter;

class C {
@augmented()
static String get staticGetter1 => "Original";
@augmented()
String get instanceGetter1 => "Original";

@augmented()
augment static String get staticGetter1;
@augmented()
augment String get instanceGetter1;
}

augment class C {
@augmented() augment static String get staticGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() static String get staticGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() augment String get instanceGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() String get instanceGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

mixin M {
@augmented()
static String get staticGetter1 => "Original";
@augmented()
String get instanceGetter1 => "Original";

@augmented()
augment static String get staticGetter1;
@augmented()
augment String get instanceGetter1;
}

augment mixin M {
@augmented() augment static String get staticGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() static String get staticGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() augment String get instanceGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() String get instanceGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
e0;

@augmented()
static String get staticGetter1 => "Original";
@augmented()
String get instanceGetter1 => "Original";

@augmented()
augment static String get staticGetter1;
@augmented()
augment String get instanceGetter1;
}

augment enum E {
e1;

@augmented() augment static String get staticGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() static String get staticGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() augment String get instanceGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() String get instanceGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

class A {}

extension Ext on A {
@augmented()
static String get staticGetter1 => "Original";
@augmented()
String get instanceGetter1 => "Original";

@augmented()
augment static String get staticGetter1;
@augmented()
augment String get instanceGetter1;
}

augment extension Ext {
@augmented() augment static String get staticGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() static String get staticGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() augment String get instanceGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() String get instanceGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET(int _) {
@augmented()
static String get staticGetter1 => "Original";
@augmented()
String get instanceGetter1 => "Original";

@augmented()
augment static String get staticGetter1;
@augmented()
augment String get instanceGetter1;
}

augment extension type ET {
@augmented() augment static String get staticGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() static String get staticGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() augment String get instanceGetter1;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented() String get instanceGetter2 => "Augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
topLevelGetter;
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
// 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 The exact result of an `augmented` expression depends on what is
/// being augmented, but it generally follows the same rules as any normal
/// identifier:
/// ...
/// - Augmenting setters: Within an augmenting setter `augmented` must be
/// followed by an `=` and will directly invoke the augmented setter. If
/// augmenting a variable with a setter, this will invoke the implicitly
/// induced setter from the augmented variable declaration.
///
/// @description Checks that it is a compile-time error if in an augmenting
/// scope an augmenting setter has a metadata named `augmented`.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

const augmented = 0;

@augmented
void set topLevelSetter(String value) {}

@augmented
augment void set topLevelSetter(String value) {}

class C {
@augmented
static void set staticSetter1(String value) {}
@augmented
void set instanceSetter1(String value) {}

@augmented
augment static void set staticSetter1(String value);
@augmented
augment void set instanceSetter1(String value);
}

augment class C {
@augmented augment static void set staticSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented static void set staticSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented augment void set instanceSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented void set instanceSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

mixin M {
@augmented
static void set staticSetter1(String value) {}
@augmented
void set instanceSetter1(String value) {}

@augmented
augment static void set staticSetter1(String value);
@augmented
augment void set instanceSetter1(String value);
}

augment mixin M {
@augmented augment static void set staticSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented static void set staticSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented augment void set instanceSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented void set instanceSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
e0;

@augmented
static void set staticSetter1(String value) {}
@augmented
void set instanceSetter1(String value) {}

@augmented
augment static void set staticSetter1(String value);
@augmented
augment void set instanceSetter1(String value);
}

augment enum E {
e1;

@augmented augment static void set staticSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented static void set staticSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented augment void set instanceSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented void set instanceSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

class A {}

extension Ext on A {
@augmented
static void set staticSetter1(String value) {}
@augmented
void set instanceSetter1(String value) {}

@augmented
augment static void set staticSetter1(String value);
@augmented
augment void set instanceSetter1(String value);
}

augment extension Ext {
@augmented augment static void set staticSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented static void set staticSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented augment void set instanceSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented void set instanceSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET(int _) {
@augmented
static void set staticSetter1(String value) {}
@augmented
void set instanceSetter1(String value) {}

@augmented
augment static void set staticSetter1(String value);
@augmented
augment void set instanceSetter1(String value);
}

augment extension type ET {
@augmented augment static void set staticSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented static void set staticSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented augment void set instanceSetter1(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
@augmented void set instanceSetter2(String value) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
topLevelSetter = "1";
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Loading
Loading