Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: optional handling in the JVM #2951

Merged
merged 1 commit into from
Oct 2, 2024
Merged

Conversation

stuartwdouglas
Copy link
Collaborator

For Kotlin this should exactly match the language semantics. For Java types are not considered Optional unless they are wrapped in a java.util.Optional, or annotated with @nullable.

The exception to this are the boxed primitive types, which are always considered nullable.

fixes: #2356

@stuartwdouglas stuartwdouglas requested review from a team and alecthomas as code owners October 2, 2024 04:43
@stuartwdouglas stuartwdouglas requested review from a team and worstell and removed request for a team October 2, 2024 04:43
This was referenced Oct 2, 2024
@stuartwdouglas stuartwdouglas marked this pull request as draft October 2, 2024 05:44
@stuartwdouglas stuartwdouglas force-pushed the stuartwdouglas/2356 branch 2 times, most recently from 29dfe85 to 9b199e8 Compare October 2, 2024 06:13
For Kotlin this should exactly match the language semantics. For Java
types are not considered Optional unless they are wrapped in a java.util.Optional,
or annotated with @nullable.

The exception to this are the boxed primitive types, which are always considered nullable.

fixes: #2356
@stuartwdouglas stuartwdouglas marked this pull request as ready for review October 2, 2024 06:15
return client.call(val);
}

@Export
@Verb
public byte[] optionalBytesVerb(byte[] val, OptionalBytesVerbClient client) {
public byte @Nullable [] optionalBytesVerb(byte @Nullable [] val, OptionalBytesVerbClient client) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the typical place for an annotation on an array?!

Copy link
Collaborator Author

@stuartwdouglas stuartwdouglas Oct 2, 2024

Choose a reason for hiding this comment

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

@Nullable Object[] is an array with nullable elements, Object @Nullable [] is an array that can be null.

It's very weird syntax and not very common, you generally don't want nullable arrays anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suuuuper weird!

@stuartwdouglas stuartwdouglas merged commit ddc902c into main Oct 2, 2024
93 checks passed
@stuartwdouglas stuartwdouglas deleted the stuartwdouglas/2356 branch October 2, 2024 06:54
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.

Make sure schema generation handles optional properly
2 participants