I'm trying to set up a Kotlin/Spring project using Spring Boot 2.0.0.M4 and Spring Framework 5.0.0.M4 and have ran into trouble with WebTestClient in a mocked-server test.
Essentially the following in Java works fine:
But Kotlin is unable to infer the type T of apply method:
With the following code:
The problem is to do with the generic typings, I'm still fairly new to Kotlin but if I write my test using the same package as ApplicationContextSpec (since they're package-private) and do the following, it works as expected:
I think the following:
should be changed to return ApplicationContextSpec (or at least AbstractMockServerSpec<ApplicationContextSpec>):
and make the class ApplicationContextSpec public. The constructor can still be default visibility so users won't be able to misuse the class outside of the defined API, and users in Kotlin will be able to import it for type inference.