From 31124f678d4a8691c52b3bec29c7719317acd5e9 Mon Sep 17 00:00:00 2001 From: "Sergey G. Grekhov" Date: Tue, 19 Nov 2024 18:39:13 +0200 Subject: [PATCH] #2956. Update and rename existing tests for type `void` (#2978) Update and rename existing tests for type `void`. Part 1 & 2. --- .../Type_Void/permitted_use_A13_t01.dart | 34 ++++++++++ .../Type_Void/permitted_use_A13_t02.dart | 30 +++++++++ .../Type_Void/permitted_use_A13_t03.dart | 23 +++++++ Language/Types/Type_Void/syntax_t01.dart | 17 ----- Language/Types/Type_Void/syntax_t02.dart | 15 ----- Language/Types/Type_Void/syntax_t03.dart | 18 ------ Language/Types/Type_Void/syntax_t04.dart | 15 ----- Language/Types/Type_Void/syntax_t05.dart | 17 ----- Language/Types/Type_Void/syntax_t06.dart | 20 ------ Language/Types/Type_Void/syntax_t07.dart | 20 ------ Language/Types/Type_Void/syntax_t08.dart | 20 ------ Language/Types/Type_Void/syntax_t09.dart | 21 ------- Language/Types/Type_Void/syntax_t11.dart | 18 ------ Language/Types/Type_Void/syntax_t12.dart | 23 ------- Language/Types/Type_Void/syntax_t13.dart | 20 ------ Language/Types/Type_Void/syntax_t14.dart | 22 ------- Language/Types/Type_Void/syntax_t15.dart | 18 ------ .../Types/Type_Void/type_void_A01_t01.dart | 17 +++++ .../Types/Type_Void/type_void_A01_t02.dart | 18 ++++++ .../Types/Type_Void/type_void_A02_t01.dart | 17 +++++ .../Types/Type_Void/type_void_A02_t02.dart | 16 +++++ .../Types/Type_Void/type_void_A03_t01.dart | 28 +++++++++ .../Types/Type_Void/type_void_A03_t02.dart | 41 ++++++++++++ .../Types/Type_Void/type_void_A03_t03.dart | 31 ++++++++++ .../Types/Type_Void/type_void_A04_t01.dart | 62 +++++++++++++++++++ .../Types/Type_Void/type_void_A04_t02.dart | 41 ++++++++++++ .../Types/Type_Void/type_void_A05_t01.dart | 43 +++++++++++++ ...syntax_t10.dart => type_void_A06_t01.dart} | 22 ++++--- .../Types/Type_Void/type_void_A06_t02.dart | 18 ++++++ .../Types/Type_Void/type_void_A06_t03.dart | 18 ++++++ .../Types/Type_Void/type_void_A06_t04.dart | 18 ++++++ .../Types/Type_Void/type_void_A06_t06.dart | 20 ++++++ .../Types/Type_Void/type_void_A06_t07.dart | 18 ++++++ .../Types/Type_Void/type_void_A06_t08.dart | 18 ++++++ .../Types/Type_Void/type_void_A06_t09.dart | 18 ++++++ .../Types/Type_Void/type_void_A06_t10.dart | 23 +++++++ .../Types/Type_Void/type_void_A06_t11.dart | 20 ++++++ .../Types/Type_Void/type_void_A07_t01.dart | 19 ++++++ ...{using_t02.dart => type_void_A07_t02.dart} | 22 ++++--- .../Types/Type_Void/type_void_A07_t03.dart | 45 ++++++++++++++ .../Types/Type_Void/type_void_A07_t04.dart | 27 ++++++++ .../Types/Type_Void/type_void_A07_t05.dart | 47 ++++++++++++++ .../Types/Type_Void/type_void_A07_t06.dart | 29 +++++++++ Language/Types/Type_Void/using_t01.dart | 22 ------- Language/Types/Type_Void/using_t03.dart | 20 ------ ...t_extension_member_invocation_A03_t01.dart | 6 +- ...t_extension_member_invocation_A03_t02.dart | 30 +++++++++ 47 files changed, 797 insertions(+), 328 deletions(-) create mode 100644 Language/Types/Type_Void/permitted_use_A13_t01.dart create mode 100644 Language/Types/Type_Void/permitted_use_A13_t02.dart create mode 100644 Language/Types/Type_Void/permitted_use_A13_t03.dart delete mode 100644 Language/Types/Type_Void/syntax_t01.dart delete mode 100644 Language/Types/Type_Void/syntax_t02.dart delete mode 100644 Language/Types/Type_Void/syntax_t03.dart delete mode 100644 Language/Types/Type_Void/syntax_t04.dart delete mode 100644 Language/Types/Type_Void/syntax_t05.dart delete mode 100644 Language/Types/Type_Void/syntax_t06.dart delete mode 100644 Language/Types/Type_Void/syntax_t07.dart delete mode 100644 Language/Types/Type_Void/syntax_t08.dart delete mode 100644 Language/Types/Type_Void/syntax_t09.dart delete mode 100644 Language/Types/Type_Void/syntax_t11.dart delete mode 100644 Language/Types/Type_Void/syntax_t12.dart delete mode 100644 Language/Types/Type_Void/syntax_t13.dart delete mode 100644 Language/Types/Type_Void/syntax_t14.dart delete mode 100644 Language/Types/Type_Void/syntax_t15.dart create mode 100644 Language/Types/Type_Void/type_void_A01_t01.dart create mode 100644 Language/Types/Type_Void/type_void_A01_t02.dart create mode 100644 Language/Types/Type_Void/type_void_A02_t01.dart create mode 100644 Language/Types/Type_Void/type_void_A02_t02.dart create mode 100644 Language/Types/Type_Void/type_void_A03_t01.dart create mode 100644 Language/Types/Type_Void/type_void_A03_t02.dart create mode 100644 Language/Types/Type_Void/type_void_A03_t03.dart create mode 100644 Language/Types/Type_Void/type_void_A04_t01.dart create mode 100644 Language/Types/Type_Void/type_void_A04_t02.dart create mode 100644 Language/Types/Type_Void/type_void_A05_t01.dart rename Language/Types/Type_Void/{syntax_t10.dart => type_void_A06_t01.dart} (51%) create mode 100644 Language/Types/Type_Void/type_void_A06_t02.dart create mode 100644 Language/Types/Type_Void/type_void_A06_t03.dart create mode 100644 Language/Types/Type_Void/type_void_A06_t04.dart create mode 100644 Language/Types/Type_Void/type_void_A06_t06.dart create mode 100644 Language/Types/Type_Void/type_void_A06_t07.dart create mode 100644 Language/Types/Type_Void/type_void_A06_t08.dart create mode 100644 Language/Types/Type_Void/type_void_A06_t09.dart create mode 100644 Language/Types/Type_Void/type_void_A06_t10.dart create mode 100644 Language/Types/Type_Void/type_void_A06_t11.dart create mode 100644 Language/Types/Type_Void/type_void_A07_t01.dart rename Language/Types/Type_Void/{using_t02.dart => type_void_A07_t02.dart} (51%) create mode 100644 Language/Types/Type_Void/type_void_A07_t03.dart create mode 100644 Language/Types/Type_Void/type_void_A07_t04.dart create mode 100644 Language/Types/Type_Void/type_void_A07_t05.dart create mode 100644 Language/Types/Type_Void/type_void_A07_t06.dart delete mode 100644 Language/Types/Type_Void/using_t01.dart delete mode 100644 Language/Types/Type_Void/using_t03.dart create mode 100644 LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A03_t02.dart diff --git a/Language/Types/Type_Void/permitted_use_A13_t01.dart b/Language/Types/Type_Void/permitted_use_A13_t01.dart new file mode 100644 index 0000000000..6a8e46ad13 --- /dev/null +++ b/Language/Types/Type_Void/permitted_use_A13_t01.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2011, 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 In support of the notion that the value of an expression with +/// static type `void` should be discarded, such objects can only be used in +/// specific situations: The occurrence of an expression of type `void` is a +/// compile-time error unless it is permitted according to one of the following +/// rules. +/// ... +/// - An actual parameter expression corresponding to a formal parameter whose +/// statically known type annotation is `void` may have type `void`. +/// +/// @description Checks that it is not an error to declare a function with a +/// formal parameter which has a type `void`. +/// @author iefremov + +void topLevelFunction(void v) {} + +class C { + static void staticMethod(void v) {} + void instanceMethod(void v) {} +} + +main() { + localFunction(void a) {}; + var f = (void v) {}; + + topLevelFunction(null); + C.staticMethod(0); + C().instanceMethod(Object()); + localFunction(""); + f(42 as dynamic); +} diff --git a/Language/Types/Type_Void/permitted_use_A13_t02.dart b/Language/Types/Type_Void/permitted_use_A13_t02.dart new file mode 100644 index 0000000000..72305d64ec --- /dev/null +++ b/Language/Types/Type_Void/permitted_use_A13_t02.dart @@ -0,0 +1,30 @@ +// 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 In support of the notion that the value of an expression with +/// static type `void` should be discarded, such objects can only be used in +/// specific situations: The occurrence of an expression of type `void` is a +/// compile-time error unless it is permitted according to one of the following +/// rules. +/// ... +/// - An actual parameter expression corresponding to a formal parameter whose +/// statically known type annotation is `void` may have type `void`. +/// +/// @description Checks that it is not an error to declare a record with a +/// parameter which has a type `void`. +/// @author sgrekhov22@gmail.com + +typedef R1 = (void v,); +typedef R2 = ({void v}); + +main() { + R1 r1 = (1,); + R2 r2 = (v: 2); + (void v,) r3 = (3,); + ({void v}) r4 = (v: 4); + print(r1); + print(r2); + print(r3); + print(r4); +} diff --git a/Language/Types/Type_Void/permitted_use_A13_t03.dart b/Language/Types/Type_Void/permitted_use_A13_t03.dart new file mode 100644 index 0000000000..96ae47d2b0 --- /dev/null +++ b/Language/Types/Type_Void/permitted_use_A13_t03.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 In support of the notion that the value of an expression with +/// static type `void` should be discarded, such objects can only be used in +/// specific situations: The occurrence of an expression of type `void` is a +/// compile-time error unless it is permitted according to one of the following +/// rules. +/// ... +/// - An actual parameter expression corresponding to a formal parameter whose +/// statically known type annotation is `void` may have type `void`. +/// +/// @description Checks that it is not an error to declare an extension type +/// with a representation type `void`. +/// @author sgrekhov22@gmail.com + +extension type ET(void v) {} + +main() { + ET et = ET(42); + print(et); +} diff --git a/Language/Types/Type_Void/syntax_t01.dart b/Language/Types/Type_Void/syntax_t01.dart deleted file mode 100644 index 158e59e907..0000000000 --- a/Language/Types/Type_Void/syntax_t01.dart +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that with generalized void specifying [void] as a type -/// argument causes no compile-time error. -/// @author iefremov - - -class A {} - -main() { - A? a = null; -} diff --git a/Language/Types/Type_Void/syntax_t02.dart b/Language/Types/Type_Void/syntax_t02.dart deleted file mode 100644 index 7966e1f1a7..0000000000 --- a/Language/Types/Type_Void/syntax_t02.dart +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that with generalized void specifying [void] as a -/// function's parameter type causes no compile-time error. -/// @author iefremov - - -main() { - f(void a) {}; -} diff --git a/Language/Types/Type_Void/syntax_t03.dart b/Language/Types/Type_Void/syntax_t03.dart deleted file mode 100644 index 0d09e248b5..0000000000 --- a/Language/Types/Type_Void/syntax_t03.dart +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that specifying void as a function's parameter type -/// (C-style, without the parameter name) causes a compile-time error. -/// @author iefremov - - -main() { - f(void) {}; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/Language/Types/Type_Void/syntax_t04.dart b/Language/Types/Type_Void/syntax_t04.dart deleted file mode 100644 index 822690b00d..0000000000 --- a/Language/Types/Type_Void/syntax_t04.dart +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that with generalized void specifying void as the type of -/// a local variable causes no compile-time error. -/// @author iefremov - - -main() { - void v = null; -} diff --git a/Language/Types/Type_Void/syntax_t05.dart b/Language/Types/Type_Void/syntax_t05.dart deleted file mode 100644 index edb1ee83f8..0000000000 --- a/Language/Types/Type_Void/syntax_t05.dart +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that specifying void on the right side of a type test -/// expression causes a compile-time error. -/// @author iefremov - -main() { - bool b = null is void; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/Language/Types/Type_Void/syntax_t06.dart b/Language/Types/Type_Void/syntax_t06.dart deleted file mode 100644 index d5c8d61f4e..0000000000 --- a/Language/Types/Type_Void/syntax_t06.dart +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that putting void in a class's extends clause causes a -/// compile-time error. -/// @author iefremov - - -class A extends void {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified - -main() { - new A(); -} diff --git a/Language/Types/Type_Void/syntax_t07.dart b/Language/Types/Type_Void/syntax_t07.dart deleted file mode 100644 index 71fbbdf151..0000000000 --- a/Language/Types/Type_Void/syntax_t07.dart +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that putting void in a class's implements clause causes -/// a compile-time error. -/// @author iefremov - - -class A implements void {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified - -main() { - new A(); -} diff --git a/Language/Types/Type_Void/syntax_t08.dart b/Language/Types/Type_Void/syntax_t08.dart deleted file mode 100644 index c5683d8fd9..0000000000 --- a/Language/Types/Type_Void/syntax_t08.dart +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a function: -/// it is a compile-time error to use void in any other context (for example, -/// as a type argument, or as the type of a variable or parameter). -/// @description Checks that specifying void as a type parameter bound causes a -/// compile-time error. -/// @author iefremov - - -class A {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified - -main() { - new A(); -} diff --git a/Language/Types/Type_Void/syntax_t09.dart b/Language/Types/Type_Void/syntax_t09.dart deleted file mode 100644 index f4beafd6a7..0000000000 --- a/Language/Types/Type_Void/syntax_t09.dart +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that with generalized void using [void] it is a -/// compile-time error to pass a value with static type void to the function -/// which takes an Object -/// @issue 30177 -/// @author sgrekhov@unipro.ru - -void v = null; - -main() { - print(v); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/Language/Types/Type_Void/syntax_t11.dart b/Language/Types/Type_Void/syntax_t11.dart deleted file mode 100644 index 7f85ca9175..0000000000 --- a/Language/Types/Type_Void/syntax_t11.dart +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that using void as a declaration name is also a c -/// ompile-time error. -/// @author rodionov - - -main() { - var void; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/Language/Types/Type_Void/syntax_t12.dart b/Language/Types/Type_Void/syntax_t12.dart deleted file mode 100644 index 9b19516c7d..0000000000 --- a/Language/Types/Type_Void/syntax_t12.dart +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that using void as a declaration name is also a -/// compile-time error. -/// @author rodionov - - -class void {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified - -main() { - new void(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/Language/Types/Type_Void/syntax_t13.dart b/Language/Types/Type_Void/syntax_t13.dart deleted file mode 100644 index 833928114c..0000000000 --- a/Language/Types/Type_Void/syntax_t13.dart +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that using void as a declaration name is also a -/// compile-time error. -/// @author rodionov - - -typedef void void(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - -main() { - void x; -} diff --git a/Language/Types/Type_Void/syntax_t14.dart b/Language/Types/Type_Void/syntax_t14.dart deleted file mode 100644 index 117c894b84..0000000000 --- a/Language/Types/Type_Void/syntax_t14.dart +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that using void as a parameter name is also a -/// compile-time error. -/// @author rodionov - - -int foo(var void) => 42; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - -main() { - foo(1); -// ^ -// [cfe] unspecified -} diff --git a/Language/Types/Type_Void/syntax_t15.dart b/Language/Types/Type_Void/syntax_t15.dart deleted file mode 100644 index 06498e1ef2..0000000000 --- a/Language/Types/Type_Void/syntax_t15.dart +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2011, 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that using void as a parameter name is also a -/// compile-time error. -/// @author rodionov - - -main() { - (var p1, var void) => p1; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/Language/Types/Type_Void/type_void_A01_t01.dart b/Language/Types/Type_Void/type_void_A01_t01.dart new file mode 100644 index 0000000000..011a04c4ad --- /dev/null +++ b/Language/Types/Type_Void/type_void_A01_t01.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that specifying `void` as a function's parameter type +/// (without the parameter name) causes a syntax error. +/// @author iefremov + +main() { + f(void) {}; +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/Language/Types/Type_Void/type_void_A01_t02.dart b/Language/Types/Type_Void/type_void_A01_t02.dart new file mode 100644 index 0000000000..878868247c --- /dev/null +++ b/Language/Types/Type_Void/type_void_A01_t02.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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is not an error to specify a type alias of the +/// type `void` as a function parameter name. +/// @author sgrekhov22@gmail.com + +typedef Void = void; + +Void f(Void) {} + +main() { + f(42); +} diff --git a/Language/Types/Type_Void/type_void_A02_t01.dart b/Language/Types/Type_Void/type_void_A02_t01.dart new file mode 100644 index 0000000000..a10232fa4f --- /dev/null +++ b/Language/Types/Type_Void/type_void_A02_t01.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that specifying `void` on the right side of an `is` +/// expression causes a syntax error. +/// @author iefremov + +main() { + bool b = null is void; +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/Language/Types/Type_Void/type_void_A02_t02.dart b/Language/Types/Type_Void/type_void_A02_t02.dart new file mode 100644 index 0000000000..37d6c4cfd6 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A02_t02.dart @@ -0,0 +1,16 @@ +// 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is not an error to specify the type alias of the +/// type `void` on the right side of an `is` expression. +/// @author sgrekhov22@gmail.com + +typedef Void = void; + +main() { + bool b = null is Void; +} diff --git a/Language/Types/Type_Void/type_void_A03_t01.dart b/Language/Types/Type_Void/type_void_A03_t01.dart new file mode 100644 index 0000000000..4fce86e730 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A03_t01.dart @@ -0,0 +1,28 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a compile-time error to extend the type +/// `void` or its alias (this is a syntax error, but there are semantic reasons +/// as well). +/// @author iefremov + +typedef Void = void; + +class A extends void {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified + +class C extends Void {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { + print(A); + print(C); +} diff --git a/Language/Types/Type_Void/type_void_A03_t02.dart b/Language/Types/Type_Void/type_void_A03_t02.dart new file mode 100644 index 0000000000..0da80bfc31 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A03_t02.dart @@ -0,0 +1,41 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a compile-time error to implement the type +/// `void` or its alias (this is a syntax error, but there are semantics reasons +/// as well). +/// @author iefremov +/// @issue 39552 + +typedef Void = void; + +class A implements void {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +class C implements Void {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +extension type ET1(void _) implements void {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +extension type ET2(void _) implements Void {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { + print(A); + print(C); + print(ET1); + print(ET2); +} diff --git a/Language/Types/Type_Void/type_void_A03_t03.dart b/Language/Types/Type_Void/type_void_A03_t03.dart new file mode 100644 index 0000000000..ed3057c80c --- /dev/null +++ b/Language/Types/Type_Void/type_void_A03_t03.dart @@ -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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a compile-time error to use `void` or its +/// alias in a mixin `on` clause, but it is not an error to use it in the +/// on-type of an extension. +/// @author sgrekhov22@gmail.com + +typedef Void = void; + +mixin M1 on void {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +mixin M2 on Void {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +extension Ext1 on void {} // Extensions are allowed on every type, including void +extension Ext2 on Void {} + +main() { + print(M1); + print(M2); +} diff --git a/Language/Types/Type_Void/type_void_A04_t01.dart b/Language/Types/Type_Void/type_void_A04_t01.dart new file mode 100644 index 0000000000..9a81b7e398 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A04_t01.dart @@ -0,0 +1,62 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that specifying `void` as a type parameter bound causes +/// a compile-time error (which is a syntax error). +/// @author iefremov + +void f() {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified> + +class A {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +class B { + static void foo() {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified> + void bar() {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified> +} + +mixin M {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +enum E { +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + e0; +} + +class C {} +extension Ext on C {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +extension type ET(int _) {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { + print(A); + print(M); + print(E); + print(C); + print(ET); +} diff --git a/Language/Types/Type_Void/type_void_A04_t02.dart b/Language/Types/Type_Void/type_void_A04_t02.dart new file mode 100644 index 0000000000..21abf3f65d --- /dev/null +++ b/Language/Types/Type_Void/type_void_A04_t02.dart @@ -0,0 +1,41 @@ +// 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is not an error to specify an alias of the type +/// `void` as a type parameter bound. +/// @author sgrekhov22@gmail.com + +typedef Void = void; + +void f() {} + +class A {} + +class B { + static void foo() {} + void bar() {} +} + +mixin M {} + +enum E { + e0; +} + +class C {} + +extension Ext on C {} + +extension type ET(int _) {} + +main() { + print(A); + print(M); + print(E); + print(C); + print(ET); +} diff --git a/Language/Types/Type_Void/type_void_A05_t01.dart b/Language/Types/Type_Void/type_void_A05_t01.dart new file mode 100644 index 0000000000..7ed8049611 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A05_t01.dart @@ -0,0 +1,43 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a compile-time error to pass a value with +/// static type `void` to the function which expecting a non-void argument. +/// @issue 30177 +/// @author sgrekhov@unipro.ru + +void v = null; + +void foo(dynamic _) {} +void bar(Null _) {} + +main() { + print(v); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + print(print("print() returns void")); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + foo(v); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + foo(print("")); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + bar(v); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + bar(print("")); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/Language/Types/Type_Void/syntax_t10.dart b/Language/Types/Type_Void/type_void_A06_t01.dart similarity index 51% rename from Language/Types/Type_Void/syntax_t10.dart rename to Language/Types/Type_Void/type_void_A06_t01.dart index 8ebe376656..5f7a27969c 100644 --- a/Language/Types/Type_Void/syntax_t10.dart +++ b/Language/Types/Type_Void/type_void_A06_t01.dart @@ -2,22 +2,28 @@ // 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 The special type void may only be used as the return type of a -/// function: it is a compile-time error to use void in any other context. -/// For example, as a type argument, or as the type of a variable or parameter. -/// @description Checks that using void as a declaration name is also a -/// compile-time error. +/// @assertion The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that using `void` as a declaration name is a syntax +/// error. /// @author rodionov - void void() {} -// ^ +// ^^^^^ // [analyzer] unspecified // [cfe] unspecified +void test() { + var void; +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { void(); -// ^ +// ^^ // [analyzer] unspecified // [cfe] unspecified } diff --git a/Language/Types/Type_Void/type_void_A06_t02.dart b/Language/Types/Type_Void/type_void_A06_t02.dart new file mode 100644 index 0000000000..0d6005c7a7 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A06_t02.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a syntax error to declare a class named +/// `void`. +/// @author rodionov + +class void {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { +} diff --git a/Language/Types/Type_Void/type_void_A06_t03.dart b/Language/Types/Type_Void/type_void_A06_t03.dart new file mode 100644 index 0000000000..60269ff2d1 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A06_t03.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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a syntax error to declare a mixin named +/// `void`. +/// @author sgrekhov22@gmail.com + +mixin void {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { +} diff --git a/Language/Types/Type_Void/type_void_A06_t04.dart b/Language/Types/Type_Void/type_void_A06_t04.dart new file mode 100644 index 0000000000..c21d88a922 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A06_t04.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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a syntax error to declare an enum named +/// `void`. +/// @author sgrekhov22@gmail.com + +enum void {e0;} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { +} diff --git a/Language/Types/Type_Void/type_void_A06_t06.dart b/Language/Types/Type_Void/type_void_A06_t06.dart new file mode 100644 index 0000000000..36bd04780b --- /dev/null +++ b/Language/Types/Type_Void/type_void_A06_t06.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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a syntax error to declare an extension named +/// `void`. +/// @author sgrekhov22@gmail.com + +class A {} + +extension void on A {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { +} diff --git a/Language/Types/Type_Void/type_void_A06_t07.dart b/Language/Types/Type_Void/type_void_A06_t07.dart new file mode 100644 index 0000000000..2dedc76a09 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A06_t07.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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a syntax error to declare an extension type +/// named `void`. +/// @author sgrekhov22@gmail.com + +extension type void(int _) {} +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { +} diff --git a/Language/Types/Type_Void/type_void_A06_t08.dart b/Language/Types/Type_Void/type_void_A06_t08.dart new file mode 100644 index 0000000000..3fb4f5eacb --- /dev/null +++ b/Language/Types/Type_Void/type_void_A06_t08.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a syntax error to use `void` as a name in an +/// old-style typedef. +/// @author rodionov + +typedef int void(); +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { +} diff --git a/Language/Types/Type_Void/type_void_A06_t09.dart b/Language/Types/Type_Void/type_void_A06_t09.dart new file mode 100644 index 0000000000..11e2ab698c --- /dev/null +++ b/Language/Types/Type_Void/type_void_A06_t09.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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a syntax error to use `void` as a name in a +/// typedef. +/// @author sgrekhov22@gmail.com + +typedef void = int; +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { +} diff --git a/Language/Types/Type_Void/type_void_A06_t10.dart b/Language/Types/Type_Void/type_void_A06_t10.dart new file mode 100644 index 0000000000..dc6325095b --- /dev/null +++ b/Language/Types/Type_Void/type_void_A06_t10.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that using `void` as a formal parameter name is a syntax +/// error. +/// @author rodionov + +int foo(var void) => 42; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + +main() { + (var p1, var void) => p1; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(foo); +} diff --git a/Language/Types/Type_Void/type_void_A06_t11.dart b/Language/Types/Type_Void/type_void_A06_t11.dart new file mode 100644 index 0000000000..69560f0737 --- /dev/null +++ b/Language/Types/Type_Void/type_void_A06_t11.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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a syntax error to use `void` as a record +/// field name. +/// @author sgrekhov22@gmail.com + +main() { + Record r1 = (void: 42); +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ({int void}) r2 = (void: 2); +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified} diff --git a/Language/Types/Type_Void/type_void_A07_t01.dart b/Language/Types/Type_Void/type_void_A07_t01.dart new file mode 100644 index 0000000000..4bf58c7aab --- /dev/null +++ b/Language/Types/Type_Void/type_void_A07_t01.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2011, 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that using a result of a `void` method invocation in an +/// expression results in a compile-time error. +/// @author rodionov + +void foo() {} + +main() { + bool b = (foo() == 1); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/Language/Types/Type_Void/using_t02.dart b/Language/Types/Type_Void/type_void_A07_t02.dart similarity index 51% rename from Language/Types/Type_Void/using_t02.dart rename to Language/Types/Type_Void/type_void_A07_t02.dart index 716ed60e69..7ad1995889 100644 --- a/Language/Types/Type_Void/using_t02.dart +++ b/Language/Types/Type_Void/type_void_A07_t02.dart @@ -2,21 +2,23 @@ // 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 In an expression of the form e1 = e2 where e1 is an -/// assignableExpression denoting a variable or parameter of type void, e2 may -/// have the type void. +/// @assertion The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// /// @description Checks that it is a compile error when assigning the result of -/// a void method invocation to a variable whose declared type is not dynamic +/// a `void` method invocation to a variable whose declared type is not `void` /// @author sgrekhov@unipro.ru - -void foo() { - return; -} +void foo() {} main() { - int i = foo(); -// ^ + dynamic i = foo(); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + + Object? j = foo(); +// ^^^ // [analyzer] unspecified // [cfe] unspecified } diff --git a/Language/Types/Type_Void/type_void_A07_t03.dart b/Language/Types/Type_Void/type_void_A07_t03.dart new file mode 100644 index 0000000000..d5d89a05cb --- /dev/null +++ b/Language/Types/Type_Void/type_void_A07_t03.dart @@ -0,0 +1,45 @@ +// 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a compile error to use a `void` expression as +/// an actual parameter. +/// @author sgrekhov22@gmail.com + +typedef R1 = (void v,); +typedef R2 = ({void v}); +extension type ET(void v) {} + +main() { + R1 r1 = (1,); + R2 r2 = (v: 2); + (void v,) r3 = (3,); + ({void v}) r4 = (v: 4); + + print(ET(1).v); +// ^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + print(r1.$1); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + print(r2.v); +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + print(r3.$1); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(r4.v); +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/Language/Types/Type_Void/type_void_A07_t04.dart b/Language/Types/Type_Void/type_void_A07_t04.dart new file mode 100644 index 0000000000..ddba1fce9d --- /dev/null +++ b/Language/Types/Type_Void/type_void_A07_t04.dart @@ -0,0 +1,27 @@ +// 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a compile error to use a `void` expression as +/// an actual parameter. +/// @author sgrekhov22@gmail.com + +extension type ET(void v) { + void test() { + print(v); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + print(this.v); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(ET); +} diff --git a/Language/Types/Type_Void/type_void_A07_t05.dart b/Language/Types/Type_Void/type_void_A07_t05.dart new file mode 100644 index 0000000000..625c36b24c --- /dev/null +++ b/Language/Types/Type_Void/type_void_A07_t05.dart @@ -0,0 +1,47 @@ +// 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a compile error to use a `void` expression as +/// an actual parameter. Test an alias of the type `void`. +/// @author sgrekhov22@gmail.com + +typedef Void = void; + +typedef R1 = (Void v,); +typedef R2 = ({Void v}); +extension type ET(Void v) {} + +main() { + R1 r1 = (1,); + R2 r2 = (v: 2); + (Void v,) r3 = (3,); + ({Void v}) r4 = (v: 4); + + print(ET(1).v); +// ^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + print(r1.$1); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + print(r2.v); +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + print(r3.$1); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(r4.v); +// ^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/Language/Types/Type_Void/type_void_A07_t06.dart b/Language/Types/Type_Void/type_void_A07_t06.dart new file mode 100644 index 0000000000..3398c34e3c --- /dev/null +++ b/Language/Types/Type_Void/type_void_A07_t06.dart @@ -0,0 +1,29 @@ +// 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 The special type `void` is used to indicate that the value of an +/// expression is meaningless and intended to be discarded. +/// +/// @description Checks that it is a compile error to use an alias of the type +/// `void` expression as an actual parameter. +/// @author sgrekhov22@gmail.com + +typedef Void = void; + +extension type ET(Void v) { + void test() { + print(v); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + print(this.v); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(ET); +} diff --git a/Language/Types/Type_Void/using_t01.dart b/Language/Types/Type_Void/using_t01.dart deleted file mode 100644 index 9fea91500e..0000000000 --- a/Language/Types/Type_Void/using_t01.dart +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) 2011, 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 Hence, the static checker will issue warnings if one attempts to -/// access a member of the result of a void method invocation (even for members -/// of null, such as ==). Likewise, passing the result of a void method as a -/// parameter or assigning it to a variable will cause a warning unless the -/// variable/formal parameter has type dynamic. -/// @description Checks that using the result of a void method invocation in an -/// expression results in a compile error. -/// @author rodionov - - -void foo() {return;} - -main() { - bool b = (foo() == 1); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/Language/Types/Type_Void/using_t03.dart b/Language/Types/Type_Void/using_t03.dart deleted file mode 100644 index cf6f6d10ab..0000000000 --- a/Language/Types/Type_Void/using_t03.dart +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2011, 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 Hence, the static checker will issue warnings if one attempts to -/// access a member of the result of a void method invocation (even for members -/// of null, such as ==). Likewise, passing the result of a void method as a -/// parameter or assigning it to a variable will cause a warning unless the -/// variable/formal parameter has type dynamic. -/// @description Checks that assigning the result of a void method invocation to -/// a variable whose declared type is dynamic does not cause any warnings or -/// errors. -/// @author rodionov - - -void foo() {return;} - -main() { - var i = foo(); -} diff --git a/LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A03_t01.dart b/LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A03_t01.dart index 69e4093975..80257c13b3 100644 --- a/LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A03_t01.dart +++ b/LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A03_t01.dart @@ -3,15 +3,13 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if the static type of the argument -/// expression (expr) of an explicit extension invocation is void. +/// expression (expr) of an explicit extension invocation is `void`. /// /// @description Check that it is a compile-time error if the static type of the -/// argument expression (expr) of an explicit extension invocation is void. +/// argument expression (expr) of an explicit extension invocation is `void`. /// @issue 39156 /// @author sgrekhov@unipro.ru - - class C { String name = "My name is C"; } diff --git a/LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A03_t02.dart b/LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A03_t02.dart new file mode 100644 index 0000000000..565fbb3435 --- /dev/null +++ b/LanguageFeatures/Extension-methods/explicit_extension_member_invocation_A03_t02.dart @@ -0,0 +1,30 @@ +// 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 the static type of the argument +/// expression (expr) of an explicit extension invocation is `void`. +/// +/// @description Check that it is a compile-time error if the static type of the +/// argument expression (expr) of an explicit extension invocation is `void`. +/// @author sgrekhov22@gmail.com +/// @issue 57082 + +extension ExtVoid on void { + void checkme() { + print("I'm extension"); + } +} + +main() { + void v = 42; + v.checkme(); +//^ +// [analyzer] unspecified +// [cfe] unspecified + + ExtVoid(print("print() returns void")).checkme(); +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +}