Skip to content

Make lookup API context extend nullable Object #5172

Merged
modmuss50 merged 1 commit intoFabricMC:26.1from
deirn:deirn/null-api-api
Feb 3, 2026
Merged

Make lookup API context extend nullable Object #5172
modmuss50 merged 1 commit intoFabricMC:26.1from
deirn:deirn/null-api-api

Conversation

@deirn
Copy link
Member

@deirn deirn commented Jan 29, 2026

@NullMarked makes the lookup context C non-nullable by default.
This is not ideal since C comes from the usage of the API and thus should allow for null if needed.
For example, the transfer API has a nullable Direction context for sided storages.

Before

Screenshot_20260130_011606 Screenshot_20260130_011636 Screenshot_20260130_011701

After

Screenshot_20260130_013915 No warnings here. Note that I needed to invalidate the cache and reload the project for the warning to go away, classic IntelliJank.

@Toffikk
Copy link
Contributor

Toffikk commented Jan 29, 2026

why not just mark the context as nullable? it would be much cleaner if possible

@deirn
Copy link
Member Author

deirn commented Jan 29, 2026

Then it will always nullable. You want C to control it.

@cputnam-a11y
Copy link
Contributor

why not just mark the context as nullable? it would be much cleaner if possible

Yeah, I would do this, marking the context as potentially Nullable like C extends @Nullable Object as jspecify recommends

@deirn
Copy link
Member Author

deirn commented Jan 29, 2026

That a thing? TIL. I'll take a look later then.
I also looked on @UnknownNullability from JetBrains annotation, but you can't use it on the type parameter.

@deirn deirn force-pushed the deirn/null-api-api branch from 58ff32b to a37b367 Compare January 30, 2026 14:43
@deirn deirn changed the title Use manual null annotations for lookup API Make lookup API context extend nullable Object Jan 30, 2026
@deirn
Copy link
Member Author

deirn commented Jan 30, 2026

Extending nullable Object seems to be working.

@modmuss50 modmuss50 added the status: merge me please Pull requests that are ready to merge label Feb 3, 2026
@modmuss50 modmuss50 merged commit 834cb82 into FabricMC:26.1 Feb 3, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

small change status: merge me please Pull requests that are ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants