Files
kotlin-fork/compiler/testData/codegen/boxInline/reified/kt18977.kt
T
Mikhael Bogdanov f7ce8c18c6 Add tests for Obsolete issues
#KT-18977 Obsolete
2019-01-09 10:20:54 +01:00

26 lines
717 B
Kotlin
Vendored

// FILE: 1.kt
package test
class AbstractTreeNode<T>(val value: T, val parent: AbstractTreeNode<T>?)
internal inline fun <reified T : Any> AbstractTreeNode<*>.findNotNullValueOfType(strict: Boolean = false): T {
return findValueOfType(strict)!!
}
internal inline fun <reified T : Any> AbstractTreeNode<*>.findValueOfType(strict: Boolean = true): T? {
var current: AbstractTreeNode<*>? = if (strict) this.parent else this
while (current != null) {
val value = current.value
if (value is T) return value
current = current.parent
}
return null
}
// FILE: 2.kt
import test.*
fun box(): String {
return AbstractTreeNode("OK", null).findNotNullValueOfType<String>()!!
}