Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2559. Add augmented expression tests for functions #2630

Merged
merged 6 commits into from
May 2, 2024
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 @@ -17,6 +17,8 @@

import augment 'augmented_expression_A01_t10_lib.dart';

String get topLevelGetter => "Original";

class C {
static String get staticGetter => "Original";
String get instanceGetter => "Original";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// SharedOptions=--enable-experiment=macros

augment library 'augmented_expression_A01_t04.dart';
augment library 'augmented_expression_A01_t10.dart';

augment String get topLevelGetter {
var augmented = "x";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// 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 functions: When augmenting a function, augmented refers to the
/// augmented function. Tear offs are not allowed, so this function must
/// immediately be invoked.
///
/// @description Checks that it is a compile-time error to tear-off `augmented`
/// expression inside of an augmenting function
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

import augment 'augmented_expression_A04_t01_lib1.dart';
import augment 'augmented_expression_A04_t01_lib2.dart';

const augmented = "Augmented constant, should not be used";

void topLevelFunction() {}

class C {
static void staticMethod() {}
void instanceMethod() {}
final augmented = "C.augmented, should not be used";
}

mixin M {
static void staticMethod() {}
void instanceMethod() {}
final augmented = "M.augmented, should not be used";
}

enum E {
e1;

static void staticMethod() {}
void instanceMethod() {}
final augmented = "E.augmented, should not be used";
}

class A {}

extension Ext on A {
static void staticMethod() {}
void instanceMethod() {}
final augmented = "Ext.augmented, should not be used";
}

main() {
print(topLevelFunction);
print(C);
print(M);
print(E);
print(A);
}
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 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 functions: When augmenting a function, augmented refers to the
/// augmented function. Tear offs are not allowed, so this function must
/// immediately be invoked.
///
/// @description Checks that it is a compile-time error to tear-off `augmented`
/// expression inside of an augmenting function
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

augment library 'augmented_expression_A04_t01.dart';

augment void topLevelFunction() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment class C {
augment static void staticMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment mixin M {
augment static void staticMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment enum E {
augment e1;

augment static void staticMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}

augment extension Ext {
augment static void staticMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
augment void instanceMethod() {
var f = augmented;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// 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 functions: When augmenting a function, augmented refers to the
/// augmented function. Tear offs are not allowed, so this function must
/// immediately be invoked.
///
/// @description Checks that it is a compile-time error to tear-off `augmented`
/// expression inside of an augmenting function
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

augment library 'augmented_expression_A04_t01.dart';

augment void topLevelFunction() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}

augment class C {
augment static void staticMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
augment void instanceMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
}

augment mixin M {
augment static void staticMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
augment void instanceMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
}

augment enum E {
augment e1;

augment static void staticMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
augment void instanceMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
}

augment extension Ext {
augment static void staticMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
augment void instanceMethod() {
var f = () {
augmented.toString();
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// 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 functions: When augmenting a function, augmented refers to the
/// augmented function. Tear offs are not allowed, so this function must
/// immediately be invoked.
///
/// @description Checks that it is a compile-time error to declare a local
/// variable named `augmented` inside of an augmenting function
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

import augment 'augmented_expression_A04_t02_lib.dart';

void topLevelFunction() {}

class C {
static void staticMethod() {}
void instanceMethod() {}
}

mixin M {
static void staticMethod() {}
void instanceMethod() {}
}

enum E {
e1;

static void staticMethod() {}
void instanceMethod() {}
}

class A {}

extension Ext on A {
static void staticMethod() {}
void instanceMethod() {}
}

main() {
print(topLevelFunction);
print(C);
print(M);
print(E);
print(A);
}
Loading