-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Move Null to the bottom of nullable types #28024
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
Can we add some negative and positive tests for this feature so that we can verify the implementations. |
Spec is complete, moving this to 1.22 for implementation. |
Siva wrote:
@floitschG do we have some shared tests in place? |
I have landed a test (language/null_bottom_test) and Johnni has landed some too when he made the dart2js implementation ( If you find something that isn't covered, please say so, and I'll add to the tests. |
Issue to clarify what methods are on |
Marking dart2js and vm done |
Marking Analyzer done |
Assigning to Florian for getting changelog updated. |
In Dart 1,
dynamic
was equivalent to bothtop
(akaObject
) andbottom
(subclass of every type). In strong mode,dynamic
only stands forObject
(+ dynamic calls). This means that aList<dynamic>
is not a subclass ofList<int>
anymore.Usually, there are ways to replace
dynamic
with a better type, but in some cases, one would actually want to provide a type that is a subtype of all other types. A very common one is, for example,const <Bottom>[]
where the constant empty list would like to be used for any other list.Since, in Dart1, all types are nullable, the
null
value dynamically already has the bottom type. With this bug we also change theNull
type to be at the bottom of the typing hierarchy:Null <: A
for everyA
. This makes sense:List<Null>
is aList<int>
(sincenull
is anint
).Once we have nullable types we should introduce a non-nullable version of
Null
(calledNothing
). See #27488The text was updated successfully, but these errors were encountered: