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

Throw exception if Kotlin projection requires non-null value but null result present #3244

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Feb 14, 2025

Fix GH-3242

KFunction<?> function = KotlinDetector.isKotlinType(method.getDeclaringClass()) ?
KotlinReflectionUtils.findKotlinFunction(method) : null;
if (function != null && !function.getReturnType().isMarkedNullable()) {
throw new IllegalArgumentException("Kotlin function '%s' requires non-null return value".formatted(method.toString()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure exception type and message is appropriate.

christophstrobl pushed a commit that referenced this pull request Mar 6, 2025
… result present

Closes: #3242
Original Pull Request: #3244

Signed-off-by: Yanming Zhou <[email protected]>
christophstrobl added a commit that referenced this pull request Mar 6, 2025
christophstrobl pushed a commit that referenced this pull request Mar 6, 2025
Align nullness/nullability wording. Use template methods instead of functions to create exceptions.

Original Pull Request: #3244
@christophstrobl
Copy link
Member

Thank you @quaff! Merged to main development line.

@christophstrobl christophstrobl added this to the 3.5 M2 (2025.0.0) milestone Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Kotlin Interface projections nullabillity issues
3 participants