-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
281 additions
and
22 deletions.
There are no files selected for viewing
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
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
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
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
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
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
54 changes: 54 additions & 0 deletions
54
LanguageFeatures/Augmentation-libraries/augmenting_members_A02_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,54 @@ | ||
// 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: | ||
/// ... | ||
/// A non-writable variable declaration is augmented with a setter. | ||
/// | ||
/// @description Checks that it is a compile-time error if a getter declaration | ||
/// is augmented with a setter. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmenting_members_A02_t04_lib.dart'; | ||
|
||
String get topLevelGetter => "topLevelGetter"; | ||
|
||
class C { | ||
static String get staticGetter => "staticGetter"; | ||
String get instanceGetter => "instanceGetter"; | ||
} | ||
|
||
mixin M { | ||
static String get staticGetter => "staticGetter"; | ||
String get instanceGetter => "instanceGetter"; | ||
} | ||
|
||
enum E { | ||
e0; | ||
static String get staticGetter => "staticGetter"; | ||
String get instanceGetter => "instanceGetter"; | ||
} | ||
|
||
class A {} | ||
|
||
extension Ext on A { | ||
static String get staticGetter => "staticGetter"; | ||
String get instanceGetter => "instanceGetter"; | ||
} | ||
|
||
extension type ET(String _) { | ||
static String get staticGetter => "staticGetter"; | ||
String get instanceGetter => "instanceGetter"; | ||
} | ||
|
||
main() { | ||
print(topLevelGetter); | ||
print(C); | ||
print(M); | ||
print(E); | ||
print(A); | ||
print(ET); | ||
} |
76 changes: 76 additions & 0 deletions
76
LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t04_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,76 @@ | ||
// 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: | ||
/// ... | ||
/// A non-writable variable declaration is augmented with a setter. | ||
/// | ||
/// @description Checks that it is a compile-time error if a getter declaration | ||
/// is augmented with a setter. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmenting_members_A02_t04.dart'; | ||
|
||
/**/augment void set topLevelGetter(String _) {} | ||
// ^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
augment class C { | ||
augment static void set staticGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
augment void set instanceGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
augment mixin M { | ||
augment static void set staticGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
augment void set instanceGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
augment enum E { | ||
augment e0; | ||
augment static void set staticGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
augment void set instanceGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
augment extension Ext { | ||
augment static void set staticGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
augment void set instanceGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
augment extension type ET { | ||
augment static void set staticGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
augment void set instanceGetter(String _) {} | ||
//^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
66 changes: 66 additions & 0 deletions
66
LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t05.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,66 @@ | ||
// 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: | ||
/// ... | ||
/// A non-writable variable declaration is augmented with a setter. | ||
/// | ||
/// @description Checks that it is not an error to augment a `late final` | ||
/// variable declaration with no initializer with a setter. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import augment 'augmenting_members_A02_t05_lib.dart'; | ||
import '../../Utils/expect.dart'; | ||
|
||
String _log = ""; | ||
|
||
late final String topLevelVariable; | ||
|
||
class C { | ||
static late final String staticVariable; | ||
late final String instanceVariable; | ||
} | ||
|
||
mixin M { | ||
static late final String staticVariable; | ||
late final String instanceVariable; | ||
} | ||
|
||
enum E { | ||
e0; | ||
static late final String staticVariable; | ||
} | ||
|
||
class A {} | ||
|
||
extension Ext on A { | ||
static late final String staticVariable; | ||
} | ||
|
||
extension type ET(String _) { | ||
static late final String staticVariable; | ||
} | ||
|
||
class MA = Object with M; | ||
|
||
main() { | ||
topLevelVariable = "a"; | ||
Expect.equals("Augmented: a", _log); | ||
C.staticVariable = "b"; | ||
Expect.equals("Augmented: b", _log); | ||
C().instanceVariable = "c"; | ||
Expect.equals("Augmented: c", _log); | ||
M.staticVariable = "d"; | ||
Expect.equals("Augmented: d", _log); | ||
MA().instanceVariable = "e"; | ||
Expect.equals("Augmented: e", _log); | ||
E.staticVariable = "f"; | ||
Expect.equals("Augmented: f", _log); | ||
Ext.staticVariable = "g"; | ||
Expect.equals("Augmented: g", _log); | ||
ET.staticVariable = "h"; | ||
Expect.equals("Augmented: h", _log); | ||
} |
58 changes: 58 additions & 0 deletions
58
LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t05_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,58 @@ | ||
// 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: | ||
/// ... | ||
/// A non-writable variable declaration is augmented with a setter. | ||
/// | ||
/// @description Checks that it is not an error to augment a `late final` | ||
/// variable declaration with no initializer with a setter. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
augment library 'augmenting_members_A02_t05.dart'; | ||
|
||
augment void set topLevelVariable(String v) { | ||
_log = "Augmented: $v"; | ||
} | ||
|
||
augment class C { | ||
augment static void set staticVariable(String v) { | ||
_log = "Augmented: $v"; | ||
} | ||
|
||
augment void set instanceVariable(String v) { | ||
_log = "Augmented: $v"; | ||
} | ||
} | ||
|
||
augment mixin M { | ||
augment static void set staticVariable(String v) { | ||
_log = "Augmented: $v"; | ||
} | ||
|
||
augment void set instanceVariable(String v) { | ||
_log = "Augmented: $v"; | ||
} | ||
} | ||
|
||
augment enum E { | ||
augment e0; | ||
augment static void set staticVariable(String v) { | ||
_log = "Augmented: $v"; | ||
} | ||
} | ||
|
||
augment extension Ext { | ||
augment static void set staticVariable(String v) { | ||
_log = "Augmented: $v"; | ||
} | ||
} | ||
|
||
augment extension type ET { | ||
augment static void set staticVariable(String v) { | ||
_log = "Augmented: $v"; | ||
} | ||
} |