blob: 7636e5d408f58dfcb934dd1cdbfd48e39f475a0c [file]
// ISSUE: KT-89949
// WITH_REFLECT
// FILE: JavaVal.java
public value class JavaVal {
public final int x;
public JavaVal(int x) {
this.x = x;
}
}
// FILE: test.kt
import java.time.LocalDate
import java.util.Optional
import kotlin.reflect.full.primaryConstructor
@JvmInline
value class KInline(val x: Int)
class WithLocalDate(val d: LocalDate)
class WithOptional(val o: Optional<String>)
class WithJavaVal(val j: JavaVal)
data class Event(val name: String, val date: LocalDate)
fun mixed(k: KInline, d: LocalDate): Int = k.x + d.year
fun LocalDate.plusInline(k: KInline): LocalDate = plusDays(k.x.toLong())
fun box(): String {
if (!LocalDate::class.isValue || !JavaVal::class.isValue) return "Fail: isValue"
val date = LocalDate.of(2020, 1, 2)
val withLocalDate = WithLocalDate::class.primaryConstructor!!
if (withLocalDate.call(date).d != date) return "Fail: WithLocalDate.call"
if (withLocalDate.callBy(mapOf(withLocalDate.parameters.single() to date)).d != date) return "Fail: WithLocalDate.callBy"
if (WithOptional::class.primaryConstructor!!.call(Optional.of("o")).o.get() != "o") return "Fail: WithOptional"
if (WithJavaVal::class.primaryConstructor!!.call(JavaVal(1)).j.x != 1) return "Fail: WithJavaVal"
if (Event::class.primaryConstructor!!.call("e", date) != Event("e", date)) return "Fail: Event"
if (::mixed.call(KInline(1), date) != 2021) return "Fail: mixed"
if (LocalDate::plusInline.call(date, KInline(1)) != LocalDate.of(2020, 1, 3)) return "Fail: plusInline"
if (date::plusInline.call(KInline(2)) != LocalDate.of(2020, 1, 4)) return "Fail: bound plusInline"
return "OK"
}