Add maybe types - #26814
Draft
odersky wants to merge 24 commits into
Draft
Conversation
odersky
force-pushed
the
add-maybe-types
branch
2 times, most recently
from
August 17, 2026 21:06
917f514 to
2cce1f6
Compare
- Enabled by experimental.magic - Independent of language.postfixOps - Highest precedence
ExtractDependencies fell into a "NoDenotation cannot be cast to ClassDenotation" assertioin violation. When recompiling after some changes. This fix avoids that.
Otherwise the maybe logic does not work correctly. It would be nice if we could link explicit-nulls with magic, but that does not work since explicit-nulls is a global flag that has to be set when the compiler starts up. We can't even change it from run to run.
Special cases needed for subtyping, erasure, and pattern matching.
The erasure of Maybe changes after bootstrapped. So anything that touches it can compile only with the bootstrapped compiler.
Also: Drop $ in front of Maybe, no harm in using it directly, since it is a sealed trait. Also: Fix exhaustivity checking for Ok patterns
- Drop OK unapply call, which is known to be the identity - Simplify leading null test for maybe types
Also, move back bootstrapped library and tests to regular. Since we now inline Ok.unapply, we are no longer affected by difference in erasure between bootstrapped and non-bootstrapped.
Plus a lot more tests
odersky
force-pushed
the
add-maybe-types
branch
from
August 19, 2026 17:02
18a8b6b to
f5e85b2
Compare
Needed to avoid erasure difference between bootstrapped and non-bootstrapped compilers.
So for T not nullable, we now have T? =:= T | Null.
We don't need it directly, since source programs use `?` instead. Also: Fix printing of maybe type trees.
Also: drop overfitted condition by Claude in space engine.
odersky
force-pushed
the
add-maybe-types
branch
from
August 21, 2026 10:54
5b673b7 to
334ace1
Compare
To reduce added linecount we drop a bunch of tests that are straightforward Option -> ? substitutions.
odersky
force-pushed
the
add-maybe-types
branch
from
August 21, 2026 14:44
339631c to
d740b53
Compare
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.
Trial balloon for a new kind of maybe type
T?.