diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t01.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t01.dart new file mode 100644 index 0000000000..3b5bddac4a --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t01.dart @@ -0,0 +1,56 @@ +// 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 Declarations in any library augmentation or the augmented library +/// are visible to all of the others, including private ones. +/// +/// @description Checks that declarations in an augmentation are visible in a +/// main library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import '../../Utils/expect.dart'; +import augment 'defining_augmentation_A01_t01_lib.dart'; + +extension on C1 { + String get z => "z"; +} + +extension on _C2 { + String get _z => "_z"; +} + +extension type ET1(C1 id) {} +extension type ET2(_C2 id) {} + +class MA1 = Object with M1; +class MA2 = Object with _M2; + +main() { + Expect.equals("y", C1().y); + Expect.equals("z", C1().z); + Expect.equals("m", MA1().m); + Expect.equals("_y", _C2()._y); + Expect.equals("_z", _C2()._z); + Expect.equals("_m", MA2()._m); + Expect.equals("y", ET1(C1()).id.y); + Expect.equals("_y", ET2(_C2()).id._y); + Expect.equals(E1.e, E1.e.instance); + Expect.equals(_E2.e, _E2.e._instance); + Expect.equals(42, x1); + Expect.equals(42, _x2); + Expect.equals(0, foo1()); + Expect.equals(0, _foo2()); + Expect.equals("bar", [].bar); + Expect.equals("bar", MyList([]).bar); + Expect.equals("_baz", [].baz); + Expect.equals("_baz", _MyList([]).baz); + Expect.equals(42, MyInt(42)); + Expect.equals(42, _MyInt(42)); + Expect.isTrue((Foo1 as dynamic) is Type); + Expect.isTrue((_Foo2 as dynamic) is Type); + Expect.isTrue((C1Alias as dynamic) is Type); + Expect.isTrue((_C2Alias as dynamic) is Type); +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t01_lib.dart new file mode 100644 index 0000000000..6b4c87c2c3 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t01_lib.dart @@ -0,0 +1,70 @@ +// 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 Declarations in any library augmentation or the augmented library +/// are visible to all of the others, including private ones. +/// +/// @description Checks that declarations in an augmentation are visible in a +/// main library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A01_t01.dart'; + +class C1 { + String get y => "y"; +} + +mixin M1 { + String get m => "m"; +} + +enum E1 { + e; + + E1 get instance => e; +} + +var x1 = 42; + +int foo1() => 0; + +extension MyList on List { + String get bar => "bar"; +} + +extension type MyInt(int id) {} + +typedef void Foo1(); + +typedef C1Alias = C1; + +class _C2 { + String get _y => "_y"; +} + +mixin _M2 { + String get _m => "_m"; +} + +enum _E2 { + e; + + _E2 get _instance => e; +} + +var _x2 = 42; + +int _foo2() => 0; + +extension _MyList on List { + String get baz => "_baz"; +} + +extension type _MyInt(int id2) {} + +typedef void _Foo2(); + +typedef _C2Alias = _C2; diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t02.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t02.dart new file mode 100644 index 0000000000..e8ea844578 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t02.dart @@ -0,0 +1,77 @@ +// 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 Declarations in any library augmentation or the augmented library +/// are visible to all of the others, including private ones. +/// +/// @description Checks that declarations in a main library are visible in an +/// augmentation library +/// @author sgrekhov22@gmail.com +/// @issue 55103 + +// SharedOptions=--enable-experiment=macros + +import augment 'defining_augmentation_A01_t02_lib.dart'; + +import '../../Utils/expect.dart'; + +class C1 { + String get y => "y"; +} + +mixin M1 { + String get m => "m"; +} + +enum E1 { + e; + + E1 get instance => e; +} + +var x1 = 42; + +int foo1() => 0; + +extension MyList on List { + String get bar => "bar"; +} + +extension type MyInt(int id) {} + +typedef void Foo1(); + +typedef C1Alias = C1; + +class _C2 { + String get _y => "_y"; +} + +mixin _M2 { + String get _m => "_m"; +} + +enum _E2 { + e; + + _E2 get _instance => e; +} + +var _x2 = 42; + +int _foo2() => 0; + +extension _MyList on List { + String get baz => "_baz"; +} + +extension type _MyInt(int id2) {} + +typedef void _Foo2(); + +typedef _C2Alias = _C2; + +main() { + test(); +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t02_lib.dart new file mode 100644 index 0000000000..1c2b2f52fa --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A01_t02_lib.dart @@ -0,0 +1,57 @@ +// 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 Declarations in any library augmentation or the augmented library +/// are visible to all of the others, including private ones. +/// +/// @description Checks that declarations in a main library are visible in an +/// augmentation library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A01_t02.dart'; + +import '../../Utils/expect.dart'; + +extension on C1 { + String get z => "z"; +} + +extension on _C2 { + String get _z => "_z"; +} + +extension type ET1(C1 id) {} +extension type ET2(_C2 id) {} + +class MA1 = Object with M1; +class MA2 = Object with _M2; + +test() { + Expect.equals("y", C1().y); + Expect.equals("z", C1().z); + Expect.equals("m", MA1().m); + Expect.equals("_y", _C2()._y); + Expect.equals("_z", _C2()._z); + Expect.equals("_m", MA2()._m); + Expect.equals("y", ET1(C1()).id.y); + Expect.equals("_y", ET2(_C2()).id._y); + Expect.equals(E1.e, E1.e.instance); + Expect.equals(_E2.e, _E2.e._instance); + Expect.equals(42, x1); + Expect.equals(42, _x2); + Expect.equals(0, foo1()); + Expect.equals(0, _foo2()); + Expect.equals("bar", [].bar); + Expect.equals("bar", MyList([]).bar); + Expect.equals("_baz", [].baz); + Expect.equals("_baz", _MyList([]).baz); + Expect.equals(42, MyInt(42)); + Expect.equals(42, _MyInt(42)); + Expect.isTrue((Foo1 as dynamic) is Type); + Expect.isTrue((_Foo2 as dynamic) is Type); + Expect.isTrue((C1Alias as dynamic) is Type); + Expect.isTrue((_C2Alias as dynamic) is Type); +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t01.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t01.dart new file mode 100644 index 0000000000..79bb8bda58 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t01.dart @@ -0,0 +1,22 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in a main library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'defining_augmentation_A02_t01_lib.dart'; + +main() { + print(AL); +// ^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t01_lib.dart new file mode 100644 index 0000000000..4b6e40148c --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t01_lib.dart @@ -0,0 +1,19 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in a main library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A02_t01.dart'; + +import 'augmentation_libraries_lib.dart'; + +class C implements AL {} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t02.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t02.dart new file mode 100644 index 0000000000..3f6a750d09 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t02.dart @@ -0,0 +1,23 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in a main library even if an augmentation library exports it +/// @author sgrekhov22@gmail.com +/// @issue 55112 + +// SharedOptions=--enable-experiment=macros + +import augment 'defining_augmentation_A02_t02_lib.dart'; + +main() { + print(AL); +// ^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t02_lib.dart new file mode 100644 index 0000000000..a3884485ed --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t02_lib.dart @@ -0,0 +1,18 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in a main library even if an augmentation library exports it +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A02_t02.dart'; + +import 'augmentation_libraries_lib.dart'; +export 'augmentation_libraries_lib.dart'; diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03.dart new file mode 100644 index 0000000000..c133b71048 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03.dart @@ -0,0 +1,20 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in another augmentation library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'defining_augmentation_A02_t03_lib1.dart'; +import augment 'defining_augmentation_A02_t03_lib2.dart'; + +main() { + test(); +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03_lib1.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03_lib1.dart new file mode 100644 index 0000000000..26d72fe6e9 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03_lib1.dart @@ -0,0 +1,17 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in another augmentation library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A02_t03.dart'; + +import 'augmentation_libraries_lib.dart'; diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03_lib2.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03_lib2.dart new file mode 100644 index 0000000000..c0dcdac783 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t03_lib2.dart @@ -0,0 +1,22 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in another augmentation library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A02_t03.dart'; + +test() { + print(AL); +// ^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t04.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t04.dart new file mode 100644 index 0000000000..6de726480e --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t04.dart @@ -0,0 +1,20 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in another augmentation library even if it exports it +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'defining_augmentation_A02_t04_lib1.dart'; +import augment 'defining_augmentation_A02_t04_lib2.dart'; + +main() { + test(); +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t04_lib1.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t04_lib1.dart new file mode 100644 index 0000000000..d88dec577e --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t04_lib1.dart @@ -0,0 +1,18 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in another augmentation library even if it exports it +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A02_t04.dart'; + +import 'augmentation_libraries_lib.dart'; +export 'augmentation_libraries_lib.dart'; diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t04_lib2.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t04_lib2.dart new file mode 100644 index 0000000000..57c1ef5f2f --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t04_lib2.dart @@ -0,0 +1,22 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports in an augmentation library are not visible +/// in another augmentation library even if it exports it +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A02_t04.dart'; + +test() { + print(AL); +// ^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t05.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t05.dart new file mode 100644 index 0000000000..bd76c4e2c4 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t05.dart @@ -0,0 +1,21 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports from main library are not visible in an +/// augmentation library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'defining_augmentation_A02_t05_lib.dart'; + +import 'augmentation_libraries_lib.dart'; + +main() { + test(); +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t05_lib.dart new file mode 100644 index 0000000000..645416ca7e --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t05_lib.dart @@ -0,0 +1,22 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that imports from main library are not visible in an +/// augmentation library +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A02_t05.dart'; + +test() { + print(AL); +// ^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t06.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t06.dart new file mode 100644 index 0000000000..cbfb6727da --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t06.dart @@ -0,0 +1,19 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that if augment library does exports then augmented +/// library implicitly exports it +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import 'defining_augmentation_A02_t06_augmented_lib.dart'; + +main() { + print(AL); +} diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t06_augmented_lib.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t06_augmented_lib.dart new file mode 100644 index 0000000000..d9f97cfb23 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t06_augmented_lib.dart @@ -0,0 +1,15 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that if augment library does exports then augmented +/// library implicitly exports it +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'defining_augmentation_A02_t06_lib.dart'; diff --git a/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t06_lib.dart b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t06_lib.dart new file mode 100644 index 0000000000..030cf4f616 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/defining_augmentation_A02_t06_lib.dart @@ -0,0 +1,18 @@ +// 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 Augmentations do not share an import scope with the main library +/// or each other. The libraries one augmentation imports are visible only to +/// that file. +/// +/// @description Checks that if augment library does exports then augmented +/// library implicitly exports it +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'defining_augmentation_A02_t06_augmented_lib.dart'; + +import 'augmentation_libraries_lib.dart'; +export 'augmentation_libraries_lib.dart';