Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions Language/Types/Type_Void/permitted_use_A13_t01.dart
Original file line number Diff line number Diff line change
@@ -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);
}
30 changes: 30 additions & 0 deletions Language/Types/Type_Void/permitted_use_A13_t02.dart
Original file line number Diff line number Diff line change
@@ -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);
}
23 changes: 23 additions & 0 deletions Language/Types/Type_Void/permitted_use_A13_t03.dart
Original file line number Diff line number Diff line change
@@ -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);
}
17 changes: 0 additions & 17 deletions Language/Types/Type_Void/syntax_t01.dart

This file was deleted.

15 changes: 0 additions & 15 deletions Language/Types/Type_Void/syntax_t02.dart

This file was deleted.

18 changes: 0 additions & 18 deletions Language/Types/Type_Void/syntax_t03.dart

This file was deleted.

15 changes: 0 additions & 15 deletions Language/Types/Type_Void/syntax_t04.dart

This file was deleted.

17 changes: 0 additions & 17 deletions Language/Types/Type_Void/syntax_t05.dart

This file was deleted.

20 changes: 0 additions & 20 deletions Language/Types/Type_Void/syntax_t06.dart

This file was deleted.

20 changes: 0 additions & 20 deletions Language/Types/Type_Void/syntax_t07.dart

This file was deleted.

20 changes: 0 additions & 20 deletions Language/Types/Type_Void/syntax_t08.dart

This file was deleted.

21 changes: 0 additions & 21 deletions Language/Types/Type_Void/syntax_t09.dart

This file was deleted.

18 changes: 0 additions & 18 deletions Language/Types/Type_Void/syntax_t11.dart

This file was deleted.

23 changes: 0 additions & 23 deletions Language/Types/Type_Void/syntax_t12.dart

This file was deleted.

20 changes: 0 additions & 20 deletions Language/Types/Type_Void/syntax_t13.dart

This file was deleted.

22 changes: 0 additions & 22 deletions Language/Types/Type_Void/syntax_t14.dart

This file was deleted.

18 changes: 0 additions & 18 deletions Language/Types/Type_Void/syntax_t15.dart

This file was deleted.

17 changes: 17 additions & 0 deletions Language/Types/Type_Void/type_void_A01_t01.dart
Original file line number Diff line number Diff line change
@@ -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
}
Loading
Loading