mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 00:21:35 +00:00
Support mapping between Kotlin functions and JVM methods/constructors
This commit is contained in:
12
compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaConstructor.kt
vendored
Normal file
12
compiler/testData/codegen/boxAgainstJava/reflection/mapping/javaConstructor.kt
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.jvm.*
|
||||
import javaConstructor as J
|
||||
|
||||
fun box(): String {
|
||||
val reference = ::J
|
||||
val javaConstructor = reference.javaConstructor ?: return "Fail: no Constructor for reference"
|
||||
val j = javaConstructor.newInstance("OK")
|
||||
val kotlinConstructor = javaConstructor.kotlinFunction
|
||||
if (reference != kotlinConstructor) return "Fail: reference != kotlinConstructor"
|
||||
return j.result
|
||||
}
|
||||
Reference in New Issue
Block a user