Skip to content

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

Closed
quaff wants to merge 1 commit intospring-projects:mainfrom
quaff:patch-24
Closed

Throw exception if Kotlin projection requires non-null value but null result present#3244
quaff wants to merge 1 commit intospring-projects:mainfrom
quaff:patch-24

Conversation

@quaff
Copy link
Copy Markdown
Contributor

@quaff quaff commented Feb 14, 2025

Fix GH-3242

… result present

Fix spring-projectsGH-3242

Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
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
Copy Markdown
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 <zhouyanming@gmail.com>
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
Copy Markdown
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