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 more augmented expression tests #2749

Merged
merged 2 commits into from
Jul 3, 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
@@ -0,0 +1,34 @@
// 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 A compile-time error occurs if a declaration with the name
/// `augmented` occurs in a location where the outermost enclosing declaration
/// is augmenting.
///
/// @description Checks that it is a compile-time error if a declaration of a
/// variables with the name `augmented` occurs in a location where the outermost
/// enclosing declaration is augmenting.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

import augment 'augmented_expression_A09_t01_lib.dart';

class C1 {}
class C2 {}
mixin M1 {}
mixin M2 {}
enum E {e0;}

class A {}
extension Ext on A {}

main() {
print(C1);
print(C2);
print(M1);
print(M2);
print(E);
print(A);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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 A compile-time error occurs if a declaration with the name
/// `augmented` occurs in a location where the outermost enclosing declaration
/// is augmenting.
///
/// @description Checks that it is a compile-time error if a declaration of a
/// variables with the name `augmented` occurs in a location where the outermost
/// enclosing declaration is augmenting.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

augment library 'augmented_expression_A09_t01.dart';

augment class C1 {
static String augmented = "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment class C2 {
String augmented = "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M1 {
static String augmented = "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M2 {
String augmented = "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E {
augment e0;
static String augmented = "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext {
static String augmented = "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extension types can have static variables, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to add extension types to these tests after resolution of dart-lang/language#3694

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be OK to add extension type cases now, and then later on add cases where the extra freedom (e.g., leaving out the primary constructor) is used. I don't think anyone suggested that #3694 should give rise to fewer possible programs.

I'll land this now, and then those extension type cases can be added in a different PR, now or later.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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 A compile-time error occurs if a declaration with the name
/// `augmented` occurs in a location where the outermost enclosing declaration
/// is augmenting.
///
/// @description Checks that it is a compile-time error if a declaration of a
/// getter with the name `augmented` occurs in a location where the outermost
/// enclosing declaration is augmenting.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

import augment 'augmented_expression_A09_t02_lib.dart';

class C1 {}
class C2 {}
mixin M1 {}
mixin M2 {}
enum E1 {e0;}
enum E2 {e0;}

class A {}
extension Ext1 on A {}
extension Ext2 on A {}

main() {
print(C1);
print(C2);
print(M1);
print(M2);
print(E1);
print(E2);
print(A);
}
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 A compile-time error occurs if a declaration with the name
/// `augmented` occurs in a location where the outermost enclosing declaration
/// is augmenting.
///
/// @description Checks that it is a compile-time error if a declaration of a
/// getter with the name `augmented` occurs in a location where the outermost
/// enclosing declaration is augmenting.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

augment library 'augmented_expression_A09_t02.dart';

augment class C1 {
static String get augmented => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment class C2 {
String get augmented => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M1 {
static String get augmented => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M2 {
String get augmented => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E1 {
augment e0;
static String get augmented => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E2 {
augment e0;
String get augmented => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext1 {
static String get augmented => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext2 {
String get augmented => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
eernstg marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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 A compile-time error occurs if a declaration with the name
/// `augmented` occurs in a location where the outermost enclosing declaration
/// is augmenting.
///
/// @description Checks that it is a compile-time error if a declaration of a
/// method with the name `augmented` occurs in a location where the outermost
/// enclosing declaration is augmenting.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

import augment 'augmented_expression_A09_t03_lib.dart';

class C1 {}
class C2 {}
mixin M1 {}
mixin M2 {}
enum E1 {e0;}
enum E2 {e0;}

class A {}
extension Ext1 on A {}
extension Ext2 on A {}

main() {
print(C1);
print(C2);
print(M1);
print(M2);
print(E1);
print(E2);
print(A);
}
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 A compile-time error occurs if a declaration with the name
/// `augmented` occurs in a location where the outermost enclosing declaration
/// is augmenting.
///
/// @description Checks that it is a compile-time error if a declaration of a
/// method with the name `augmented` occurs in a location where the outermost
/// enclosing declaration is augmenting.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

augment library 'augmented_expression_A09_t03.dart';

augment class C1 {
static String augmented() => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment class C2 {
String augmented() => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M1 {
static String augmented() => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment mixin M2 {
String augmented() => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E1 {
augment e0;
static String augmented() => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment enum E2 {
augment e0;
String augmented() => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext1 {
static String augmented() => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension Ext2 {
String augmented() => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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 A compile-time error occurs if a declaration with the name
/// `augmented` occurs in a location where the outermost enclosing declaration
/// is augmenting.
///
/// @description Checks that it is a compile-time error if a declaration of a
/// setter with the name `augmented=` occurs in a location where the outermost
/// enclosing declaration is augmenting.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=macros

import augment 'augmented_expression_A09_t04_lib.dart';

class C1 {}
class C2 {}
mixin M1 {}
mixin M2 {}
enum E1 {e0;}
enum E2 {e0;}

class A {}
extension Ext1 on A {}
extension Ext2 on A {}

main() {
print(C1);
print(C2);
print(M1);
print(M2);
print(E1);
print(E2);
print(A);
}
Loading