Skip to content

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

Closed
5 tasks done
floitschG opened this issue Dec 7, 2016 · 8 comments
Closed
5 tasks done

Move Null to the bottom of nullable types #28024

floitschG opened this issue Dec 7, 2016 · 8 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). P1 A high priority bug; for example, a single project is unusable or has many test failures
Milestone

Comments

@floitschG
Copy link
Contributor

floitschG commented Dec 7, 2016

In Dart 1, dynamic was equivalent to both top (aka Object) and bottom (subclass of every type). In strong mode, dynamic only stands for Object (+ dynamic calls). This means that a List<dynamic> is not a subclass of List<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 the Null type to be at the bottom of the typing hierarchy: Null <: A for every A. This makes sense: List<Null> is a List<int> (since null is an int).

Once we have nullable types we should introduce a non-nullable version of Null (called Nothing). See #27488

@floitschG floitschG added the area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). label Dec 7, 2016
@floitschG floitschG added this to the 1.50 milestone Dec 7, 2016
@floitschG floitschG added the area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). label Dec 7, 2016
@a-siva
Copy link
Contributor

a-siva commented Dec 7, 2016

Can we add some negative and positive tests for this feature so that we can verify the implementations.

@mit-mit
Copy link
Member

mit-mit commented Dec 15, 2016

Spec is complete, moving this to 1.22 for implementation.

@mit-mit mit-mit modified the milestones: 1.22, 1.50 Dec 15, 2016
@mit-mit
Copy link
Member

mit-mit commented Jan 2, 2017

Siva wrote:

Can we add some negative and positive tests for this feature so that we can verify the implementations.

@floitschG do we have some shared tests in place?

@lrhn
Copy link
Member

lrhn commented Jan 4, 2017

I have landed a test (language/null_bottom_test) and Johnni has landed some too when he made the dart2js implementation (null_is_bottom{,_type}_test).

If you find something that isn't covered, please say so, and I'll add to the tests.

@leafpetersen
Copy link
Member

Issue to clarify what methods are on Null and bottom here:

#28430

@mit-mit
Copy link
Member

mit-mit commented Jan 18, 2017

Marking dart2js and vm done

@mit-mit mit-mit added P1 A high priority bug; for example, a single project is unusable or has many test failures and removed P1 A high priority bug; for example, a single project is unusable or has many test failures labels Jan 19, 2017
@mit-mit
Copy link
Member

mit-mit commented Jan 19, 2017

Marking Analyzer done

@mit-mit
Copy link
Member

mit-mit commented Jan 19, 2017

Assigning to Florian for getting changelog updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). area-meta Cross-cutting, high-level issues (for tracking many other implementation issues, ...). P1 A high priority bug; for example, a single project is unusable or has many test failures
Projects
None yet
Development

No branches or pull requests

5 participants