Skip to content

Support Kotlin parameter default values in handler methods #1741

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 2 commits into from

Conversation

diesieben07
Copy link
Contributor

Allows using default parameter values for any method parameters resolved
via AbstractNamedValueMethodArgumentResolver, similar to defaultValue
parameter of e.g. @RequestParam annotation, but skipping the converter
chain.

Issues: SPR-16598.

Allows using default parameter values for any method parameters resolved
via AbstractNamedValueMethodArgumentResolver, similar to defaultValue
parameter of e.g. @RequestParam annotation, but skipping the converter
chain.

Issues: SPR-16598
@diesieben07
Copy link
Contributor Author

Rebased onto current master and resolved merge conflicts.

@sdeleuze sdeleuze self-assigned this Apr 23, 2018
@raderio
Copy link

raderio commented May 3, 2018

An ETA when it can be merged?

@raderio
Copy link

raderio commented May 8, 2018

is something wrong with this pull request?

@snicoll
Copy link
Member

snicoll commented May 8, 2018

@raderio please be patient, we'll get to it as soon as we can.

@sdeleuze
Copy link
Contributor

Current Kotlin API forces us to have a rather involved implementation which is not a good fit with our infra. We would need a reflection API that allows Spring to know an optional parameter default value without calling the function. I will discuss with Kotlin team to see what is possible here in Kotlin 1.3.

@diesieben07
Copy link
Contributor Author

I am not sure if what you want is possible.
You can write something like this:
fun foo(a: String, b: String = a) or, even worse:
fun foo(a: String, b: String = someFunctionWithSideEffects())

This is impossible to represent in the way you propose.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 24, 2019
@diesieben07 diesieben07 closed this Aug 9, 2020
@bclozel bclozel removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 18, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants