Enable explicit-nulls and unsafe nulls by default with null under AnyVal#26296
Draft
HarrisL2 wants to merge 15 commits into
Draft
Enable explicit-nulls and unsafe nulls by default with null under AnyVal#26296HarrisL2 wants to merge 15 commits into
HarrisL2 wants to merge 15 commits into
Conversation
That removes it from the top of the hierarchy, de-emphasizing its importance. It makes sense because it has all the properties of other `AnyVal`s: "two" instances of `Null` "re-created" from the keyword `null` are indistinguishible from each other. So it has structural equality. This does not change the erasure of any type, because `AnyVal` erases to `Object` anyway. Unfortunately, this requires complicating the loading mechanism for `scala.Null`. It now extends a class that can be compiled from source, and that is incompatible with it being a "core" class that is forced in `Definitions.init()`. We make it a synthesized class instead, like the magic `FunctionN` classes. I'm not happy about this. The silver lining is that, once we actually move all-in to explicit-nulls, we will be able to define `Null` itself in source, which will remove all of that magic. If you have trouble wrapping your head around `Null <:< AnyVal`, observe that `null: Null` and `(): Unit` have a lot in common. They are both types with a singleton instance, accessible with syntax. `null` is only `== null`, and `()` is only `== ()`. Moreover, they do not have the `eq` operator.
…it-nulls-under-anyval
Contributor
|
Results of the Open Community Build on this PR can be found here: |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Testing the effects of AnyVal null by enabling it by default.
How much have you relied on LLM-based tools in this contribution?
Not at all
How was the solution tested?
Covered by existing tests (this is a refactoring)