forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dart-lang#2559. Add augmenting types tests. Part 5
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
LanguageFeatures/Augmentation-libraries/augmenting_types_A04_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,33 @@ | ||
// 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: | ||
/// ... | ||
/// - An augmenting extension declares an on clause. We don't allow filling this | ||
/// in for extensions, it must be on the original declaration. This | ||
/// restriction could be lifted later if we have a compelling use case, as | ||
/// there is no fundamental reason it cannot be allowed, although it would be | ||
/// a parse error today to have an extension with no on clause. | ||
/// | ||
/// @description Checks that it is a compile-time error if an augmenting | ||
/// extension declares an `on` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmenting_types_A04_t01_lib.dart'; | ||
|
||
class C {} | ||
|
||
extension Ext on C { | ||
String foo() => "Extension Ext on C"; | ||
} | ||
|
||
extension on C { | ||
String bar() => "Extension on C"; | ||
} | ||
|
||
main() { | ||
print(C); | ||
} |
31 changes: 31 additions & 0 deletions
31
LanguageFeatures/Augmentation-libraries/augmenting_types_A04_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,31 @@ | ||
// 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: | ||
/// ... | ||
/// - An augmenting extension declares an on clause. We don't allow filling this | ||
/// in for extensions, it must be on the original declaration. This | ||
/// restriction could be lifted later if we have a compelling use case, as | ||
/// there is no fundamental reason it cannot be allowed, although it would be | ||
/// a parse error today to have an extension with no on clause. | ||
/// | ||
/// @description Checks that it is a compile-time error if an augmenting | ||
/// extension declares an `on` clause | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmenting_types_A04_t01.dart'; | ||
|
||
augment extension on C { | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
augment extension Ext on C { | ||
// ^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |