Skip to content

Commit

Permalink
Implement review recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Aug 16, 2024
1 parent 66569db commit 1d0c541
Show file tree
Hide file tree
Showing 10 changed files with 281 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that 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 an implicitly induced
/// getter of a final variable declaration is augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros
Expand Down Expand Up @@ -38,7 +38,7 @@ extension Ext on A {
static final String staticVariable = "staticVariable";
}

extension type ET(String _) {
extension type ET(String id) {
static final String staticVariable = "staticVariable";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if an augmenting
/// declaration uses `augmented` when the augmented declaration has no concrete
/// implementation.
/// @description Checks that it is a compile-time error if an implicitly induced
/// getter of a final variable declaration is augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros
Expand Down Expand Up @@ -65,5 +64,9 @@ augment extension type ET {
augment static void set staticVariable(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
augment static void set id(String _) {}
//^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,40 @@
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if a non-writable
/// variable declaration is augmented with a setter. Test `late final` variables
/// @description Checks that it is a compile-time error if an implicitly induced
/// getter of a `late final` variable declaration with an initializer is
/// augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros

import augment 'augmenting_members_A02_t02_lib.dart';

late final String topLevelVariable;
late final String topLevelVariable = "";

class C {
static late final String staticVariable;
late final String instanceVariable;
static late final String staticVariable = "";
late final String instanceVariable = "";
}

mixin M {
static late final String staticVariable;
late final String instanceVariable;
static late final String staticVariable = "";
late final String instanceVariable = "";
}

enum E {
e0;
static late final String staticVariable;
static late final String staticVariable = "";
}

class A {}

extension Ext on A {
static late final String staticVariable;
static late final String staticVariable = "";
}

extension type ET(String _) {
static late final String staticVariable;
static late final String staticVariable = "";
}

main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if a non-writable
/// variable declaration is augmented with a setter. Test `late final` variables
/// @description Checks that it is a compile-time error if an implicitly induced
/// getter of a `late final` variable declaration with an initializer is
/// augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if a non-writable
/// variable declaration is augmented with a setter. Test `const` variables.
/// @description Checks that it is a compile-time error if a `const` variable
/// declaration is augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
/// ...
/// A non-writable variable declaration is augmented with a setter.
///
/// @description Checks that it is a compile-time error if a non-writable
/// variable declaration is augmented with a setter. Test `const` variables.
/// @description Checks that it is a compile-time error if a `const` variable
/// declaration is augmented with a setter.
/// @author sgrekhov22@gmail.com
// SharedOptions=--enable-experiment=macros
Expand Down
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);
}
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
}
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);
}
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";
}
}

0 comments on commit 1d0c541

Please sign in to comment.