Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 8 additions & 3 deletions docs/_docs/reference/experimental/explicit-nulls.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,17 @@ Read on for details.

## New Type Hierarchy

When explicit nulls are enabled, the type hierarchy changes so that `Null` is only a subtype of
`Any`, as opposed to every reference type, which means `null` is no longer a value of `AnyRef` and its subtypes.
Originally, `Null` is a subtype of all reference types.

!["Original Type Hierarchy"](images/explicit-nulls/scalaHierarchyWithMatchable.png)

When explicit nulls is enabled, the type hierarchy changes so that `Null` is only
a subtype of `Any` and `Matchable`, as opposed to every reference type,
which means `null` is no longer a value of `AnyRef` and its subtypes.

This is the new type hierarchy:

!["Type Hierarchy for Explicit Nulls"](images/explicit-nulls/explicit-nulls-type-hierarchy.png)
!["Type Hierarchy for Explicit Nulls"](images/explicit-nulls/scalaHierarchyWithMatchableAndSafeNull.png)

After erasure, `Null` remains a subtype of all reference types (as forced by the JVM).

Expand Down