When I try to compile this function I see some kind of compiler error: ```@Composable inline fun &lt...
r
When I try to compile this function I see some kind of compiler error:
Copy code
@Composable
inline fun <reified T : Any> test() {
    val kClass = T::class
}
It compiles when I remove
T::class
statement from the body.
The error is:
Copy code
e: java.lang.IllegalStateException: Symbol for [ /test|test(){0§<kotlin.Any>}[0] <- Local[<TP>,0|TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] reified:true] ] is unbound
        at org.jetbrains.kotlin.ir.symbols.impl.IrBindablePublicSymbolBase.getOwner(IrPublicSymbolBase.kt:63)
        at org.jetbrains.kotlin.backend.common.linkage.partial.PartiallyLinkedIrTreePatcher$ExpressionTransformer.checkReferencedDeclaration(PartiallyLinkedIrTreePatcher.kt:585)
        at org.jetbrains.kotlin.backend.common.linkage.partial.PartiallyLinkedIrTreePatcher$ExpressionTransformer.checkReferencedDeclaration$default(PartiallyLinkedIrTreePatcher.kt:574)
        at org.jetbrains.kotlin.backend.common.linkage.partial.PartiallyLinkedIrTreePatcher$ExpressionTransformer.visitClassReference(PartiallyLinkedIrTreePatcher.kt:492)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClassReference(IrElementTransformerVoid.kt:254)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitClassReference(IrElementTransformerVoid.kt:24)
        at org.jetbrains.kotlin.ir.expressions.IrClassReference.accept(IrClassReference.kt:26)
        at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:31)
        at org.jetbrains.kotlin.ir.declarations.IrVariable.transformChildren(IrVariable.kt:45)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid.visitDeclaration(IrElementTransformerVoid.kt:57)
I'm testing with compose-multiplatform
1.6.0-beta02
on K/JS and K/Wasm with Kotlin 1.9.22 and compose compiler plugin 1.5.8
Is it a bug or some kind of compose limitation?
It is a compose compiler bug. You can do this:
Copy code
@Composable
inline fun <reified T : Any> test() {
    val kClass = getClass<T>
}

inline fun <reified T : Any> getClass() : KClass<T> {
    return T::class
}
r
Thank you!