Background

Context Parameters were introduced in Kotlin 2.1.20 and are currently in Beta status in Kotlin 2.2.0 under the flag -Xcontext-parameters (announcement)

Issue

Spring's KotlinReflectionParameterNameDiscoverer cannot detect Context Parameters in Kotlin methods. The kotlinFunction property returns incomplete results - context parameters are completely absent from the reflection data.

Use Case

I'm migrating from Context Receivers to Context Parameters for implementing security via HandlerMethodArgumentResolver. My implementation: - Uses a custom UserContext class as a context parameter - Injects it into controller handler methods - Propagates it through service method calls

Technical Details

Expected

  1. Track support for Context Parameters in Spring Framework (if KT-78752 will be resolved)
  2. Add support for the new parameter kind coming in Kotlin 2.2.20 when reflection API is available

Comment From: sdeleuze

Let's explore that when Kotlin reflection will be fixed.