-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Analyzer const cast fails for Never?
.
#54820
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
Comments
I'm guessing that Never? f() => null; results in the lint |
I'm inclined to agree that at least Issue filed: #59388 |
We've got this one as well: #59309. |
Yes, thanks @eernstg! |
Or throw, just like It's definitely true that typedef NeverQ = Never?;
void main() {
assert(Null == NeverQ);
const t1 = Null;
const t2 = NeverQ;
assert(identical(t1, t2));
} |
There is definitely wrong error message in the analyzer in case of type class C {
Never? get foo => throw "Exception";
}
main() {
C c = C();
try {
c.foo?.bar(); // CFE: No compile error. Analyzer: The method 'bar' can't be unconditionally invoked because
// the receiver can be 'null'. Try making the call conditional (using '?.') or adding a null
// check to the target ('!').
} catch (_) {}
}
|
Example:
The analyzer reports a compile-time error for this:
Doesn't say which exception, and it shouldn't since
null
is a valid value of any nullable type.(Doesn't check type for nullability?)
The text was updated successfully, but these errors were encountered: