-
Notifications
You must be signed in to change notification settings - Fork 28
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
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
59 changes: 59 additions & 0 deletions
59
LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01_lib.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
37 changes: 37 additions & 0 deletions
37
LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
74 changes: 74 additions & 0 deletions
74
LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02_lib.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
|
37 changes: 37 additions & 0 deletions
37
LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
74 changes: 74 additions & 0 deletions
74
LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03_lib.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
37 changes: 37 additions & 0 deletions
37
LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t04.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.