Files
kotlin-fork/native/native.tests/testData/codegen/associatedObjects/associatedObjects1_testGlobalOptimizations2.kt
T
Vladimir Sukharev df2dcccbf7 [Tests] Removed moved tests from old testing
^KT-64256 Fixed
2023-12-18 11:15:15 +00:00

31 lines
710 B
Kotlin
Vendored

/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
*/
import kotlin.test.*
import kotlin.reflect.*
@OptIn(ExperimentalAssociatedObjects::class)
@AssociatedObjectKey
@Retention(AnnotationRetention.BINARY)
annotation class Associated1(val kClass: KClass<*>)
@OptIn(ExperimentalAssociatedObjects::class)
fun box(): String {
val i2 = I2ImplHolder()::class.findAssociatedObject<Associated1>()!! as I2
assertEquals(17, i2.foo())
return "OK"
}
private interface I2 {
fun foo(): Int
}
private object I2Impl : I2 {
override fun foo() = 17
}
@Associated1(I2Impl::class)
private class I2ImplHolder