mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 08:31:29 +00:00
PSI-based implementation (accessible via `-Xuse-old-class-files-reading`) loads parameter names from the "MethodParameters" attribute if it's present, so our own implementation should as well. This metadata doesn't seem supported in the java.lang.model.element API though, so SymbolBasedValueParameter (which is used in `-Xuse-javac`) will continue to have incorrect behavior for now #KT-25193 Fixed
36 lines
877 B
Kotlin
Vendored
36 lines
877 B
Kotlin
Vendored
// WITH_RUNTIME
|
|
// FULL_JDK
|
|
// JAVAC_OPTIONS: -parameters
|
|
// KOTLIN_CONFIGURATION_FLAGS: +JVM.PARAMETERS_METADATA
|
|
|
|
// FILE: JavaInterface.java
|
|
|
|
public interface JavaInterface {
|
|
void plugin(String id);
|
|
}
|
|
|
|
// FILE: test.kt
|
|
|
|
import kotlin.test.assertEquals
|
|
|
|
interface KotlinInterface {
|
|
fun plugin(id: String)
|
|
}
|
|
|
|
class KotlinDelegate(impl: KotlinInterface) : KotlinInterface by impl
|
|
|
|
class JavaDelegate(impl: JavaInterface) : JavaInterface by impl
|
|
|
|
private fun check(javaClass: Class<*>) {
|
|
val pluginMethod = javaClass.getDeclaredMethod("plugin", String::class.java)
|
|
assertEquals(listOf("id"), pluginMethod.parameters.map { it.name }, "Incorrect parameters for $javaClass")
|
|
}
|
|
|
|
fun box(): String {
|
|
check(JavaInterface::class.java)
|
|
check(KotlinInterface::class.java)
|
|
check(KotlinDelegate::class.java)
|
|
check(JavaDelegate::class.java)
|
|
return "OK"
|
|
}
|