-
Notifications
You must be signed in to change notification settings - Fork 214
Add null-safety specification of super-bounded types #1133
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
17de680
Add null-safety specification of super-bounded types
eernstg cd99123
Reordered a few words
eernstg 0f92fbd
Moved helper predicates to null safety spec, connected them to subtyping
eernstg f10723f
Change definition of super-bounded to treat "rest" positions same as …
eernstg b0b9ac9
Merge branch 'master' into spec_super_bounds_aug20
eernstg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,9 @@ [email protected] | |
|
||
## CHANGELOG | ||
|
||
2020.08.13 | ||
- Move helper predicates to the null safety specification. | ||
|
||
2020.07.21 | ||
- **CHANGE** Specify treatment of mixed hierarchies. | ||
|
||
|
@@ -14,7 +17,7 @@ This documents the currently implemented upper and lower bound computation, | |
modified to account for explicit nullability and the accompanying type system | ||
changes (including the legacy types). In the interest of backwards | ||
compatibility, it does not try to fix the various issues with the existing | ||
algorithm. | ||
algorithm. | ||
|
||
## Types | ||
|
||
|
@@ -36,72 +39,15 @@ We assume that type aliases have been expanded, and that all types are named | |
|
||
## Helper predicates | ||
|
||
The **TOP** predicate is true for any type which is in the equivalence class of | ||
top types. | ||
|
||
- **TOP**(`T?`) is true iff **TOP**(`T`) or **OBJECT**(`T`) | ||
- **TOP**(`T*`) is true iff **TOP**(`T`) or **OBJECT**(`T`) | ||
- **TOP**(`dynamic`) is true | ||
- **TOP**(`void`) is true | ||
- **TOP**(`FutureOr<T>`) is **TOP**(T) | ||
- **TOP**(T) is false otherwise | ||
|
||
The **OBJECT** predicate is true for any type which is in the equivalence class | ||
of `Object`. | ||
|
||
- **OBJECT**(`Object`) is true | ||
- **OBJECT**(`FutureOr<T>`) is **OBJECT**(T) | ||
- **OBJECT**(T) is false otherwise | ||
|
||
The **BOTTOM** predicate is true for things in the equivalence class of `Never`. | ||
|
||
- **BOTTOM**(`Never`) is true | ||
- **BOTTOM**(`X&T`) is true iff **BOTTOM**(`T`) | ||
- **BOTTOM**(`X extends T`) is true iff **BOTTOM**(`T`) | ||
- **BOTTOM**(`T`) is false otherwise | ||
|
||
The **NULL** predicate is true for things in the equivalence class of `Null` | ||
|
||
- **NULL**(`Null`) is true | ||
- **NULL**(`T?`) is true iff **NULL**(`T`) or **BOTTOM**(`T`) | ||
- **NULL**(`T*`) is true iff **NULL**(`T`) or **BOTTOM**(`T`) | ||
- **NULL**(`T`) is false otherwise | ||
|
||
The **MORETOP** predicate defines a total order on top and `Object` types. | ||
|
||
- **MORETOP**(`void`, `T`) = true | ||
- **MORETOP**(`T`, `void`) = false | ||
- **MORETOP**(`dynamic`, `T`) = true | ||
- **MORETOP**(`T`, `dynamic`) = false | ||
- **MORETOP**(`Object`, `T`) = true | ||
- **MORETOP**(`T`, `Object`) = false | ||
- **MORETOP**(`T*`, `S*`) = **MORETOP**(`T`, `S`) | ||
- **MORETOP**(`T`, `S*`) = true | ||
- **MORETOP**(`T*`, `S`) = false | ||
- **MORETOP**(`T?`, `S?`) = **MORETOP**(`T`, `S`) | ||
- **MORETOP**(`T`, `S?`) = true | ||
- **MORETOP**(`T?`, `S`) = false | ||
- **MORETOP**(`FutureOr<T>`, `FutureOr<S>`) = **MORETOP**(T, S) | ||
|
||
The **MOREBOTTOM** predicate defines an (almost) total order on bottom and | ||
`Null` types. This does not currently consistently order two different type | ||
variables with the same bound. | ||
|
||
- **MOREBOTTOM**(`Never`, `T`) = true | ||
- **MOREBOTTOM**(`T`, `Never`) = false | ||
- **MOREBOTTOM**(`Null`, `T`) = true | ||
- **MOREBOTTOM**(`T`, `Null`) = false | ||
- **MOREBOTTOM**(`T?`, `S?`) = **MOREBOTTOM**(`T`, `S`) | ||
- **MOREBOTTOM**(`T`, `S?`) = true | ||
- **MOREBOTTOM**(`T?`, `S`) = false | ||
- **MOREBOTTOM**(`T*`, `S*`) = **MOREBOTTOM**(`T`, `S`) | ||
- **MOREBOTTOM**(`T`, `S*`) = true | ||
- **MOREBOTTOM**(`T*`, `S`) = false | ||
- **MOREBOTTOM**(`X&T`, `Y&S`) = **MOREBOTTOM**(`T`, `S`) | ||
- **MOREBOTTOM**(`X&T`, `S`) = true | ||
- **MOREBOTTOM**(`S`, `X&T`) = false | ||
- **MOREBOTTOM**(`X extends T`, `Y extends S`) = **MOREBOTTOM**(`T`, `S`) | ||
|
||
This document relies on several type classification helper predicates | ||
which are specified in the | ||
[null safety specification](https://github.com/dart-lang/language/blob/master/accepted/future-releases/nnbd/feature-specification.md): | ||
**TOP**, which is true for all top types; | ||
**OBJECT**, which is true for types equivalent to `Object`; | ||
**BOTTOM**, which is true for types equivalent to `Never`; | ||
**NULL**, which is true for types equivalent to `Null`; | ||
**MORETOP**, which is a total order on top and `Object` types; and | ||
**MOREBOTTOM**, which is an (almost) total order on bottom and `Null` types. | ||
|
||
## Upper bounds | ||
|
||
|
@@ -420,7 +366,7 @@ that are not identical are `T0` and `S0` respectively, and **MORETOP**(`T0`, | |
`S0`). | ||
|
||
A similar treatment would need to be done for the bottom types as well, since | ||
there are two equivalences there. | ||
there are two equivalences there. | ||
- `X extends T` is equivalent to `Null` if `T` is equivalent to `Null`. | ||
- `FutureOr<Null>` is equivalent `Future<Null>`. | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.