Skip to content

Nullable type used in vararg leads to compilation failure #34221

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

Closed
snicoll opened this issue Jan 9, 2025 · 2 comments
Closed

Nullable type used in vararg leads to compilation failure #34221

snicoll opened this issue Jan 9, 2025 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Jan 9, 2025

I have this Kotlin code using Spring Boot 3/Spring Framework 6.2:

fun someRestCall(name: String?): Details {
	return restClient.get().uri("/{name}/details", name).retrieve().body(Details::class.java)!!
}

Where uri takes a String and a vararg of Object.

Upgrading to Spring Framework 7, I am getting:

MyService.kt:35:49 Argument type mismatch: actual type is 'kotlin.String?', but 'kotlin.Any' was expected.

I upgraded to Kotlin 2.1 in a separate commit so it looks like the extra checks might come from Spring Framework 7.0 itself. The new behavior looks more correct to me but I am wondering why it isn't failing in 6.x.

@snicoll snicoll added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 9, 2025
@snicoll snicoll transferred this issue from spring-projects/spring-boot Jan 9, 2025
@sdeleuze
Copy link
Contributor

This is a side effect of #28797 due to the fact that the related Object... uriVariables parameter element nullness was not managed with JSR 305 while it is now. The implementation indicates that URI variables are nullable and that makes sense to be lenient here, so I will refine the nullness of that API accordingly.

@sdeleuze sdeleuze self-assigned this Jan 10, 2025
@sdeleuze sdeleuze added in: web Issues in web modules (web, webmvc, webflux, websocket) type: regression A bug that is also a regression and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Jan 10, 2025
@sdeleuze sdeleuze added this to the 7.0.0-M1 milestone Jan 10, 2025
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Jan 10, 2025
sdeleuze added a commit to sdeleuze/spring-framework that referenced this issue Jan 10, 2025
@snicoll snicoll added type: task A general task and removed type: regression A bug that is also a regression labels Jan 10, 2025
@snicoll
Copy link
Member Author

snicoll commented Jan 10, 2025

I've moved this to a task as we haven't released the new behavior with the regression yet so it isn't technically one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants