Skip to content

Commit 298762a

Browse files
authored
Merge pull request #14883 from dotty-staging/fix-12689
Add class diagrams with Matchable
2 parents 79a7688 + 6a4b6a8 commit 298762a

File tree

6 files changed

+8
-3
lines changed

6 files changed

+8
-3
lines changed
Binary file not shown.
Binary file not shown.
Loading
Binary file not shown.
Loading

docs/_docs/reference/experimental/explicit-nulls.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,17 @@ Read on for details.
3131

3232
## New Type Hierarchy
3333

34-
When explicit nulls are enabled, the type hierarchy changes so that `Null` is only a subtype of
35-
`Any`, as opposed to every reference type, which means `null` is no longer a value of `AnyRef` and its subtypes.
34+
Originally, `Null` is a subtype of all reference types.
35+
36+
!["Original Type Hierarchy"](images/explicit-nulls/scalaHierarchyWithMatchable.png)
37+
38+
When explicit nulls is enabled, the type hierarchy changes so that `Null` is only
39+
a subtype of `Any` and `Matchable`, as opposed to every reference type,
40+
which means `null` is no longer a value of `AnyRef` and its subtypes.
3641

3742
This is the new type hierarchy:
3843

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

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

0 commit comments

Comments
 (0)