-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a 'Void' type for use in generics #2231
Comments
Added Area-Language, Triaged labels. |
It's not so simple. In reality, void is not a type. We get into very strange issues if we allow it as a type argument. What about a method that takes T as an argument? What does this mean if T = void? What is List<void>?. The poster child for this is Future, but in fact, Future with no type arguments serves perfectly well. Similarly, IEVent could use Dynamic or Object. |
Given that void functions in Dart return "null", isn't it just a unit type with the single value "null"?
Wouldn't that be equivalent to a List<Null>?
It works OK, but it doesn't let the API designer communicate a distinction between a future of "anything" and a future of "nothing". Given how loose we are with other stuff, that probably doesn't matter too much, but it does feel strange. |
isn' it a unit type with the single value "null"? No it isn't (I've had this conversation before - I should dig up the discussion). |
Removed Type-Defect label. |
Added WontFix label. |
…ctor, browser_launcher, cli_util, clock, collection, convert, crypto, csslib, dartdoc, ecosystem, ffi, fixnum, glob, html, http, http_multi_server, http_parser, json_rpc_2, lints, logging, markdown, matcher, mime, mockito, native, package_config, path, pool, pub_semver, shelf, source_map_stack_trace, source_maps, source_span, sse, stack_trace, stream_channel, string_scanner, term_glyph, test, test_descriptor, test_process, test_reflective_loader, tools, typed_data, usage, watcher, web_socket_channel, webdev, yaml, yaml_edit Revisions updated by `dart tools/rev_sdk_deps.dart`. args (https://github.com/dart-lang/args/compare/5a4e16f..df9b428): df9b428 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#256) 892f013 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#257) async (https://github.com/dart-lang/async/compare/75efa6c..def4482): def4482 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#253) a0ca552 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#252) bazel_worker (https://github.com/dart-lang/bazel_worker/compare/159e671..b1b6a66): b1b6a66 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#82) bb9e48d 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#81) benchmark_harness (https://github.com/dart-lang/benchmark_harness/compare/7d0d28e..59aea95): 59aea95 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#94) e3f6207 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#93) boolean_selector (https://github.com/dart-lang/boolean_selector/compare/f255921..9431e01): 9431e01 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#51) browser_launcher (https://github.com/dart-lang/browser_launcher/compare/1f69393..25bc94a): 25bc94a 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#50) cli_util (https://github.com/dart-lang/cli_util/compare/44118e3..9e48f0d): 9e48f0d 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#90) clock (https://github.com/dart-lang/clock/compare/1e75f08..200a020): 200a020 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#56) 8a2b550 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#57) collection (https://github.com/dart-lang/collection/compare/91afde4..d27bfaf): d27bfaf 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#314) 5d568ae 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#313) convert (https://github.com/dart-lang/convert/compare/c058c8f..140b2f0): 140b2f0 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#87) crypto (https://github.com/dart-lang/crypto/compare/1e26879..b38dd62): b38dd62 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#153) csslib (https://github.com/dart-lang/csslib/compare/bd30a1a..f6b68dd): f6b68dd 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#190) 4b1ee3f 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#189) dartdoc (https://github.com/dart-lang/dartdoc/compare/a3cfdc4..59947b1): 59947b14 2023-09-25 Sam Rawlins Do not hide stacktrace of DartdocFailures (#3505) d95af5c7 2023-09-25 dependabot[bot] Bump actions/checkout from 4.0.0 to 4.1.0 (#3506) ecosystem (https://github.com/dart-lang/ecosystem/compare/3da2dd3..dcbd2ee): dcbd2ee 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#184) 3006120 2023-10-01 dependabot[bot] Bump peter-evans/create-or-update-comment (#183) 69334aa 2023-10-01 dependabot[bot] Bump actions/upload-artifact (#181) 3dd6c69 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#185) 2c5523c 2023-10-01 dependabot[bot] Bump actions/cache from 3.3.1 to 3.3.2 (#182) 5b7d3fd 2023-09-28 Devon Carew update package:dart_flutter_team_lints to use the beta package:lints (#179) 297e63e 2023-09-28 Devon Carew fix an issue validating pre-release git publishing tags (#180) 1154183 2023-09-28 Moritz Check for `DO_NOT_SUBMIT` strings. (#178) bc2dd27 2023-09-28 Moritz Add api tool call for testing (#153) eb8e398 2023-09-27 Moritz Do not fail `publish` on forks (#177) f40a4eb 2023-09-25 Devon Carew improve support for '-dev' and '-wip' package versions (#173) ffi (https://github.com/dart-lang/ffi/compare/d36e05a..ee70dd4): ee70dd4 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#214) fixnum (https://github.com/dart-lang/fixnum/compare/87ed065..ef0a587): ef0a587 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#115) glob (https://github.com/dart-lang/glob/compare/9c1996f..0046533): 0046533 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#83) f6ebc74 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#84) html (https://github.com/dart-lang/html/compare/a1b193e..49e2c8e): 49e2c8e 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#228) fb2de8a 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#227) http (https://github.com/dart-lang/http/compare/1251619..88ec75e): 88ec75e 2023-10-01 dependabot[bot] Bump actions/checkout from 3 to 4 (#1025) 08143d1 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#1024) 2c99da1 2023-10-01 dependabot[bot] Bump actions/cache from 3.3.1 to 3.3.2 (#1023) http_multi_server (https://github.com/dart-lang/http_multi_server/compare/9d62ea3..03041aa): 03041aa 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#59) 5efaa07 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#58) http_parser (https://github.com/dart-lang/http_parser/compare/d2d03e7..c557f57): c557f57 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#78) a629fd6 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#79) json_rpc_2 (https://github.com/dart-lang/json_rpc_2/compare/50a3786..0521afb): 0521afb 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#104) 4782145 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#103) lints (https://github.com/dart-lang/lints/compare/b044aca..140c802): 140c802 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#158) 624a09d 2023-09-28 Devon Carew add dangling_library_doc_comments, remove prefer_void_to_null (#157) 296efaf 2023-09-28 Devon Carew remove no_wildcard_variable_uses; improve testing (#156) c266a04 2023-09-26 Devon Carew rev to 3.0.0-beta in preparation for publishing (#153) logging (https://github.com/dart-lang/logging/compare/bcaad0f..642ed21): 642ed21 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#149) 287f4cb 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#148) markdown (https://github.com/dart-lang/markdown/compare/6cfd6f1..ae766d5): ae766d5 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#556) matcher (https://github.com/dart-lang/matcher/compare/80910d6..11daad9): 11daad9 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#229) mime (https://github.com/dart-lang/mime/compare/37ef637..f3b9c49): f3b9c49 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#105) mockito (https://github.com/dart-lang/mockito/compare/097e563..610c3dc): 610c3dc 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#699) 73930cd 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#698) native (https://github.com/dart-lang/native/compare/be4aaf7..22500ea): 22500ea 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#144) 5bfc7ff 2023-10-01 dependabot[bot] Bump coverallsapp/github-action from 2.2.1 to 2.2.3 (#145) 0b7885a 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#143) package_config (https://github.com/dart-lang/package_config/compare/ae7ad83..100533d): 100533d 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#141) a4b474a 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#142) path (https://github.com/dart-lang/path/compare/96d9183..abcf38c): abcf38c 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#151) pool (https://github.com/dart-lang/pool/compare/a5bee35..4bcc7de): 4bcc7de 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#75) pub_semver (https://github.com/dart-lang/pub_semver/compare/f0be74a..8e5a58f): 8e5a58f 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#93) 81da7c8 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#92) shelf (https://github.com/dart-lang/shelf/compare/4851978..c15fc6f): c15fc6f 2023-10-01 dependabot[bot] Bump actions/cache from 3.3.1 to 3.3.2 (#386) e47c00e 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#384) b9c898e 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#385) 9b96b9b 2023-09-26 Michael Thomsen Add backend tag in pubspec.yaml (#381) source_map_stack_trace (https://github.com/dart-lang/source_map_stack_trace/compare/196d7bf..73d449c): 73d449c 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#42) 2c4840e 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#43) source_maps (https://github.com/dart-lang/source_maps/compare/eb3d40a..fc6aa16): fc6aa16 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#83) dfca7d5 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#82) source_span (https://github.com/dart-lang/source_span/compare/48d0f57..92e50bf): 92e50bf 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#102) c212afa 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#103) sse (https://github.com/dart-lang/sse/compare/eeb2588..606387e): 606387e 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#89) stack_trace (https://github.com/dart-lang/stack_trace/compare/bcf2a0b..1c36cd7): 1c36cd7 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#143) stream_channel (https://github.com/dart-lang/stream_channel/compare/0ce7ab6..bf74065): bf74065 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#95) string_scanner (https://github.com/dart-lang/string_scanner/compare/da9142c..616424c): 616424c 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#63) term_glyph (https://github.com/dart-lang/term_glyph/compare/1b28285..19abf84): 19abf84 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#42) test (https://github.com/dart-lang/test/compare/8191a35..367aa39): 367aa397 2023-10-02 Jacob MacDonald release test_core and test (#2112) 672be9d7 2023-10-02 Ben Konyi Update package:vm_service to 12.0.0 (#2110) de324cc7 2023-10-01 dependabot[bot] Bump github/codeql-action from 2.21.5 to 2.21.9 (#2106) 31b94dbb 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#2105) d56c2150 2023-10-01 dependabot[bot] Bump actions/cache from 3.0.11 to 3.3.2 (#2108) b93f1b50 2023-10-01 dependabot[bot] Bump actions/upload-artifact from 3.1.2 to 3.1.3 (#2109) a077b673 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#2107) 566d70a2 2023-09-26 Lau Ching Jun Filter test by line when kernel is compiled with --filesystem-scheme. (#2101) 7ec1bbf5 2023-09-25 Nate Bosch Drop support for legacy iframe communication (#2099) d3f4b368 2023-09-25 Nate Bosch Tighten types in test utils (#2097) 9d997910 2023-09-25 Nate Bosch Add types to Browser implementation url arguments (#2096) test_descriptor (https://github.com/dart-lang/test_descriptor/compare/030193d..55b5eac): 55b5eac 2023-10-02 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#57) c2ba59e 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#56) test_process (https://github.com/dart-lang/test_process/compare/2a6ee23..5efd0bf): 5efd0bf 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#49) test_reflective_loader (https://github.com/dart-lang/test_reflective_loader/compare/45c57d6..8593eb1): 8593eb1 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#52) 4857e22 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#53) tools (https://github.com/dart-lang/tools/compare/3c248df..f318c80): f318c80 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#177) 0480655 2023-10-01 dependabot[bot] Bump coverallsapp/github-action from 2.2.1 to 2.2.3 (#176) 73583e8 2023-09-29 Devon Carew update package:cli_config to the latest package:dart_flutter_team_lints (#171) b293897 2023-09-28 Devon Carew update to the latest package:dart_flutter_team_lints (#173) 242fdb5 2023-09-28 Devon Carew update to the latest package:dart_flutter_team_lints (#172) a51f779 2023-09-28 Elias Yishak Use constant for no op client id (#168) e83caee 2023-09-27 Moritz Allow `publish` to write comments on forks (#169) typed_data (https://github.com/dart-lang/typed_data/compare/80e8943..d1c15ed): d1c15ed 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#73) e13af06 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#74) usage (https://github.com/dart-lang/usage/compare/7b12d51..d7d2964): d7d2964 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#198) 920c6e8 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#199) watcher (https://github.com/dart-lang/watcher/compare/1aed03e..c480e2d): c480e2d 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#151) web_socket_channel (https://github.com/dart-lang/web_socket_channel/compare/af945f1..364013d): 364013d 2023-10-02 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#286) 50dada7 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#285) webdev (https://github.com/dart-lang/webdev/compare/3078f48..7c2c2d7): 7c2c2d70 2023-10-01 dependabot[bot] Bump actions/checkout from 3.2.0 to 4.1.0 (#2245) 7739a114 2023-09-26 Elliott Brooks Refactor tests to handle new `ToolConfiguration` (#2243) 4e350cde 2023-09-21 Elliott Brooks Fix issue with the inspector panel in the Dart Debug Extension (#2242) bbddba29 2023-09-21 Elliott Brooks Prepare the Dart Debug Extension for release to version 1.36 (#2241) cc5db13f 2023-09-21 Elliott Brooks Rename plainUri to debugUri and send it to the extension (#2238) 48fc725f 2023-09-20 Elliott Brooks Add a new workspaceName parameter to DWDS on start up (#2237) d2dae560 2023-09-20 Elliott Brooks Refactor: Update the parameters for `DWDS.start` (#2231) yaml (https://github.com/dart-lang/yaml/compare/ae00187..9f0d649): 9f0d649 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#153) 8e70ffb 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#152) yaml_edit (https://github.com/dart-lang/yaml_edit/compare/4a9734d..a7e7fba): a7e7fba 2023-10-01 dependabot[bot] Bump actions/checkout from 3.6.0 to 4.1.0 (#58) f33e3d0 2023-10-01 dependabot[bot] Bump dart-lang/setup-dart from 1.5.0 to 1.5.1 (#59) 8a380e8 2023-09-28 Sigurd Meldgaard Change AliasError to AliasException (#57) Change-Id: I22f88e36d2eceb03495dabcf1265e9043364e0bd Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329260 Auto-Submit: Devon Carew <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]> Commit-Queue: Devon Carew <[email protected]>
This issue was originally filed by [email protected]
It is often the case where a method or getter in a generic Class<T> has a return value of T. When constructing specializations of this type, it is desirable in many cases to apply a 'void' type constraint to T.
Consider, for example, a Future<T> which does not compute a value, but which rather marks the asynchronous completion of an operation. The use case of having a Future<void> was discussed in this forum thread:
https://groups.google.com/a/dartlang.org/group/misc/browse_thread/thread/f03889a626eda9ab/2b5397a6d92e3b7a?lnk=gst&q=Void+as+a+type&pli=1#2b5397a6d92e3b7a
Another use case that I have is for an IEvent<T>, where T represents the event arguments. In the case of an event which does not have any information to pass to its observers (other than the fact that it happened), it would be quite useful for me to apply a 'void' type constraint here.
The text was updated successfully, but these errors were encountered: