forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dart-lang#2956. Add more tests for the type
void
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 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) 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 Finally, we need to address situations involving implicit usage | ||
/// of an object whose static type can be `void`. It is a compile-time error for | ||
/// a for-in statement to have an iterator expression of type `T` such that | ||
/// `Iterator<void>` is the most specific instantiation of `Iterator` that is a | ||
/// superinterface of `T`, unless the iteration variable has type `void`. | ||
/// | ||
/// @description Checks that it is a compile-time error if in a for-in loop type | ||
/// of the iterator expression is `Iterator<void>` and the type of the iteration | ||
/// variable is not `void`. | ||
/// @author sgrekhov22@gmail.com | ||
/// @issue 57078 | ||
void main() { | ||
List<void> list = <void>[1, 2, 3]; | ||
for (Object? i in list) { | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
for (dynamic i in list) { | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
for (Null i in list) { | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} |
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,28 @@ | ||
// 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 Finally, we need to address situations involving implicit usage | ||
/// of an object whose static type can be `void`. It is a compile-time error for | ||
/// a for-in statement to have an iterator expression of type `T` such that | ||
/// `Iterator<void>` is the most specific instantiation of `Iterator` that is a | ||
/// superinterface of `T`, unless the iteration variable has type `void`. | ||
/// | ||
/// @description Checks that it is not an error if in a for-in loop type of the | ||
/// iterator expression is `Iterator<void>` and the type of the iteration | ||
/// variable is `void`. | ||
/// @author sgrekhov22@gmail.com | ||
import '../../../Utils/expect.dart'; | ||
|
||
void main() { | ||
List<void> list = <void>[1, 2, 3]; | ||
int j = 0; | ||
for (void i in list) { | ||
Expect.equals(++j, i as int); | ||
} | ||
j = 0; | ||
for (var i in list) { | ||
Expect.equals(++j, i as int); | ||
} | ||
} |
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) 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 Finally, we need to address situations involving implicit usage | ||
/// of an object whose static type can be `void`. ... It is a compile-time error | ||
/// for an asynchronous for-in statement to have a stream expression of type `T` | ||
/// such that `Stream<void>` is the most specific instantiation of `Stream` that | ||
/// is a superinterface of `T`, unless the iteration variable has type `void`. | ||
/// | ||
/// @description Checks that it is a compile-time error if in an asynchronous | ||
/// for-in loop type of the iterator expression is `Stream<void>` and the type | ||
/// of the iteration variable is not `void`. | ||
/// @author sgrekhov22@gmail.com | ||
/// @issue 57078 | ||
void main() async { | ||
Stream<void> stream = Stream<void>.fromIterable([1, 2, 3]); | ||
await for (Object? i in stream) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
await for (dynamic i in stream) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
await for (Null i in stream) { | ||
// ^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
} |
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,28 @@ | ||
// 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 Finally, we need to address situations involving implicit usage | ||
/// of an object whose static type can be `void`. ... It is a compile-time error | ||
/// for an asynchronous for-in statement to have a stream expression of type `T` | ||
/// such that `Stream<void>` is the most specific instantiation of `Stream` that | ||
/// is a superinterface of `T`, unless the iteration variable has type `void`. | ||
/// | ||
/// @description Checks that it is not an error if in an asynchronous for-in | ||
/// loop type of the iterator expression is `Stream<void>` and the type of the | ||
/// iteration variable is `void`. | ||
/// @author sgrekhov22@gmail.com | ||
import '../../../Utils/expect.dart'; | ||
|
||
void main() async { | ||
Stream<void> stream = Stream<void>.fromIterable([1, 2, 3]); | ||
int j = 0; | ||
await for (void i in stream) { | ||
Expect.equals(++j, i as int); | ||
} | ||
j = 0; | ||
await for (var i in stream) { | ||
Expect.equals(++j, i as int); | ||
} | ||
} |