-
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
Allow "void" as a type argument #27504
Comments
A That has led to errors where someone does void foo() => delegate.foo(); but the The fix for that will likely be to allow anything to be returned by a |
Status update: we need to do #27727 for 1.50, but can implement this issue at a later point. |
See flutter#6861 This silences all but two of the warnings from https://travis-ci.org/flutter/flutter/builds/176055550 One of the silenced warnings was a genuine code error. Some of the others were correct but there was no way for the analyzer to know, and I worked around them. The remainder are problems with the analyzer, specifically dart-lang/sdk#27827 and dart-lang/sdk#27504.
See #6861 This silences all but two of the warnings from https://travis-ci.org/flutter/flutter/builds/176055550 One of the silenced warnings was a genuine code error. Some of the others were correct but there was no way for the analyzer to know, and I worked around them. The remainder are problems with the analyzer, specifically dart-lang/sdk#27827 and dart-lang/sdk#27504.
Another use case could be that raw generic types could implicitly have void as their generic type parameter if the user has disabled implicit dynamic. |
@zoechi I'm not sure how that is related. |
@dskloetg Currently you can use |
|
The STRONG_MODE_INVALID_CAST_FUNCTION_EXPR is ignored in ~24 places in the Flutter code base. This seems important to address. |
I've run into two issues relating to this with code like the following: import 'dart:async';
void foo(x) {}
void main() {
Future.wait([
new Future.value().then(foo),
new Future<bool>.value(false)
]);
} On 1.22, this produces the error
|
The LUB is a continuing problem. It's not very good at handling generic classes, so the LUB of We need a better LUB, even more so now that it's used in inference too. |
I updated the issue description to reflect the current status. |
Do we have tests for this feature? |
Not yet. I'll be writing an informal spec, and I expect that we can obtain tests from multiple contributors including the language team, as we've done before. |
This is a subset of the functionality described in Generalized void meta issue #30176 |
The language will change to allow
void
as a type argument in generics (and as a type annotation in general).This comes up in cases like:
Future<void>
. Today, code either usesFuture
, which doesn't give you great static checking of the result, orFuture<Null>
, which is kind of unfamiliar to most users.AstVisitor<void>
.We also allow
void
to be the type annotation for locals, parameters, fields, ...In Dart 1,
void
should simply be treated likeObject
, except as a return type for function types (where the old behavior should be kept).In strong mode, an additional "voidness" rule will disallow assignments from
void
toObject
when the assignment is statically visible. We will update the bug when we have a document ready.void
as type annotation (and type argument) works dart_style#588The text was updated successfully, but these errors were encountered: