Skip to content

feat: JSpecify support#5365

Merged
danil-pavlov merged 5 commits intomasterfrom
jspecify-support
Feb 25, 2026
Merged

feat: JSpecify support#5365
danil-pavlov merged 5 commits intomasterfrom
jspecify-support

Conversation

@danil-pavlov
Copy link
Contributor

No description provided.

@danil-pavlov danil-pavlov requested a review from a team as a code owner February 11, 2026 13:40
| `warn` | Reports warnings. |
| `ignore` | Ignores nullability mismatches. |

For more information, see the [JSpecify user guide](https://jspecify.dev/docs/user-guide).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this to just after the annotation list as an info box or something? Having this directly after the kotlinc option might make it confusing as to what "more information" will be available at the link.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, turned it into a tip box

You can customize this the severity of JSpecify nullability diagnostics using the following compiler option:

```properties
-Xnullability-annotations=@org.jspecify.annotations:<report-level>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also a -Xjspecify-annotations=<report-level> option available which is a bit more direct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, let's use it instead

@danil-pavlov danil-pavlov requested a review from bnorm February 12, 2026 15:21
@daniCsorbaJB daniCsorbaJB self-assigned this Feb 23, 2026
Copy link
Contributor

@daniCsorbaJB daniCsorbaJB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! 💯 (thank you for adding links as well to some other nullability annotations! 🚀)
I left a couple of suggestions; please let me know what you think.

You can specify whether the compiler reports a nullability mismatch based on the information from specific types of
nullability annotations. Use the compiler option `-Xnullability-annotations=@<package-name>:<report-level>`.
In the argument, specify the fully qualified nullability annotations package and one of these report levels:
You can instruct the compiler to report a nullability mismatch based on the information from specific types of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm 🤔 What do you think about streamlining this a bit like:

You can configure how the compiler reports nullability mismatches for specific nullability annotations using the following compiler option:

* `strict` to report errors.

See the full list of supported nullability annotations in the
> [JSpecify](#jspecify-support) is the recommended choice for nullability annotations because it's the only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of phrasing it as a recommendation, what do you think of just an explanation:

JSpecify is the only supported option that uses strict reporting by default. Use it to enable strict nullability checks without additional configuration.

Or even shorter:

You can use JSpecify to enable strict nullability checks by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still should be like a recommendation note, rephrased a bit

Type variables remain "null-agnostic" until a specific nullable or non-nullable type is provided later.

* `@NullUnmarked` reverses the effect of `@NullMarked`, making all types within the scope [platform types](#null-safety-and-platform-types)
again.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this.

danil-pavlov and others added 2 commits February 24, 2026 19:47
Co-authored-by: Dániel Csorba <150924204+daniCsorbaJB@users.noreply.github.com>
Copy link
Contributor

@daniCsorbaJB daniCsorbaJB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I left one last suggestion — LGTM! 🚀

* `strict` to report errors.

See the full list of supported nullability annotations in the
> [JSpecify](#jspecify-support) is the only supported flavor that uses `strict` report level by default.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> [JSpecify](#jspecify-support) is the only supported flavor that uses `strict` report level by default.
> [JSpecify](#jspecify-support) is the only supported option that uses `strict` report level by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of packages introduced with 'flavor', so it makes sense to refer to it in the same way

@danil-pavlov danil-pavlov merged commit d22318c into master Feb 25, 2026
5 checks passed
@danil-pavlov danil-pavlov deleted the jspecify-support branch February 25, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants