-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-warningIssues with the analyzer's Warning codesIssues with the analyzer's Warning codestype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
Edit: This issue has changed a little from what was originally reported, and the consensus is that the example code should warn that the ?
in is String?
should be removed since c
is not nullable. With that removed, the static type is as expected.
--
In the following code, the variable c
is considered Object
even though it seems like the when
clause should ensure that is is String?
:
void f(Object c) {
switch (true) {
case true when c is String?:
// A value of type 'Object' can't be assigned to a variable of type 'String'.
String a = c;
}
}
I would expect it to be String?
here (or maybe even String
since it was never nullable in the first place). I'm not sure if this is a bug, a missing feature, or behaves like this for a reason I'm overlooking.
FMorschel
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-warningIssues with the analyzer's Warning codesIssues with the analyzer's Warning codestype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug