-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Update and rename existing tests for type `void`. Part 1 & 2.
- Loading branch information
Showing
47 changed files
with
797 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 [email protected] | ||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 [email protected] | ||
extension type ET(void v) {} | ||
|
||
main() { | ||
ET et = ET(42); | ||
print(et); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} |
Oops, something went wrong.