-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kotlin/Native can't use T::class in inline function of @Composable for iOS #3147
Kotlin/Native can't use T::class in inline function of @Composable for iOS #3147
Comments
This is also affecting me with Kotlin 1.9.0 and Compose multiplatform 1.5.0. This was a difficult bug to track down as the offending code was contained in a KMP library. It would be great if this could be resolved in the near future! |
I have the same issue @OptIn(ExperimentalObjCRefinement::class)
@HiddenFromObjC
inline fun <reified T : Route> routeContent(
noinline content: @Composable (route: T) -> Unit,
): RouteContent<T> =
object : RouteContent<T> {
override val id: RouteContent.Id<T> = RouteContent.Id(T::class)
@Composable
override fun Content(route: T) = content(route)
} |
@hoc081098 I was able to work around the issue by making a helper function that was not composable. It may or may not work in your situation. @Composable
inline fun <reified T : Any> doSomething() =
doSomethingWithReifiedType(getKClassForGenericType<T>())
@Composable
inline fun <reified T : Any> doSomethingWithReifiedType(clazz: KClass<T>) {
// Do something
}
// Helper to get around @Composable inlined reified types
inline fun <reified T : Any> getKClassForGenericType(): KClass<T> = T::class |
Thanks, I have just used this way to workaround this issue |
Hi @eymar, may I know how you found out the root cause? I'm facing the same problem but having no clue when looking at the build errors. |
Hi @ryanmitchener thank you for your comment. I had same issue. But I solved it with your comment. And now I don't know why it solved can you explain?? 🥲 |
@taetae98coding As far as I understand it, the only limitation is that you can't use |
@ryanmitchener thank you! |
I got the same issue on Kotlin/web Affected platforms
Versions
To Reproduce
Stacktrace
|
This issue still occurs on Kotlin native when building for iOS, versions: compose-plugin = "1.6.0" The workaround I did is to have a separate non-composable inline function which takes the reified parameter and returns the result (i.e. a string value of the name etc.). |
fixes JetBrains/compose-multiplatform#3147 there is a bug on all platforms related to incorrect `IrTypeParameterSymbol` remapping during function body transformation because of `copyWithNewTypeParams` is called on function body directly, it doesn't accumulate typeparam symbols mapping (located in signature), which leads to preserving old symbols during body transformation Test: tested against Compose Multiplatform testsuite Change-Id: If813824a3387e78910670174bd6aabe7d13e2d43 Signed-off-by: Pavel Shishkin <pavel.shishkin@jetbrains.com>
fixes JetBrains/compose-multiplatform#3147 there is a bug on all platforms related to incorrect `IrTypeParameterSymbol` remapping during function body transformation because of `copyWithNewTypeParams` is called on function body directly, it doesn't accumulate typeparam symbols mapping (located in signature), which leads to preserving old symbols during body transformation Test: tested against Compose Multiplatform testsuite Change-Id: If813824a3387e78910670174bd6aabe7d13e2d43 Signed-off-by: Pavel Shishkin <pavel.shishkin@jetbrains.com>
compiler version updated Fixes: JetBrains/compose-multiplatform#3147
…)`" (#1290) This reverts commit dc44b84. ## Proposed Changes - Since JetBrains/compose-multiplatform#3147 is fixed we can commonize this overload - Keep internal usages of this as KClass calls to avoid breaking usage of Compose with old compilers ## Testing Test: Try to call new API
version bump & test added for reified generic in composable functions Fixes #3147
fixes JetBrains/compose-multiplatform#3147 there is a bug on all platforms related to incorrect `IrTypeParameterSymbol` remapping during function body transformation because of `copyWithNewTypeParams` is called on function body directly, it doesn't accumulate typeparam symbols mapping (located in signature), which leads to preserving old symbols during body transformation Test: tested against Compose Multiplatform testsuite Change-Id: If813824a3387e78910670174bd6aabe7d13e2d43 Signed-off-by: Pavel Shishkin <pavel.shishkin@jetbrains.com>
fixes JetBrains/compose-multiplatform#3147 there is a bug on all platforms related to incorrect `IrTypeParameterSymbol` remapping during function body transformation because of `copyWithNewTypeParams` is called on function body directly, it doesn't accumulate typeparam symbols mapping (located in signature), which leads to preserving old symbols during body transformation Test: tested against Compose Multiplatform testsuite Change-Id: If813824a3387e78910670174bd6aabe7d13e2d43 ( https://android-review.googlesource.com/q/If813824a3387e78910670174bd6aabe7d13e2d43 ) Signed-off-by: Pavel Shishkin <pavel.shishkin@jetbrains.com> Moved from: androidx/androidx@faae2fb
fixes JetBrains/compose-multiplatform#3147 there is a bug on all platforms related to incorrect `IrTypeParameterSymbol` remapping during function body transformation because of `copyWithNewTypeParams` is called on function body directly, it doesn't accumulate typeparam symbols mapping (located in signature), which leads to preserving old symbols during body transformation Test: tested against Compose Multiplatform testsuite Change-Id: If813824a3387e78910670174bd6aabe7d13e2d43 ( https://android-review.googlesource.com/q/If813824a3387e78910670174bd6aabe7d13e2d43 ) Signed-off-by: Pavel Shishkin <pavel.shishkin@jetbrains.com> Moved from: androidx/androidx@faae2fb
fixes JetBrains/compose-multiplatform#3147 there is a bug on all platforms related to incorrect `IrTypeParameterSymbol` remapping during function body transformation because of `copyWithNewTypeParams` is called on function body directly, it doesn't accumulate typeparam symbols mapping (located in signature), which leads to preserving old symbols during body transformation Test: tested against Compose Multiplatform testsuite Change-Id: If813824a3387e78910670174bd6aabe7d13e2d43 ( https://android-review.googlesource.com/q/If813824a3387e78910670174bd6aabe7d13e2d43 ) Signed-off-by: Pavel Shishkin <pavel.shishkin@jetbrains.com> Moved from: androidx/androidx@faae2fb
fixes JetBrains/compose-multiplatform#3147 there is a bug on all platforms related to incorrect `IrTypeParameterSymbol` remapping during function body transformation because of `copyWithNewTypeParams` is called on function body directly, it doesn't accumulate typeparam symbols mapping (located in signature), which leads to preserving old symbols during body transformation Test: tested against Compose Multiplatform testsuite Change-Id: If813824a3387e78910670174bd6aabe7d13e2d43 ( https://android-review.googlesource.com/q/If813824a3387e78910670174bd6aabe7d13e2d43 ) Signed-off-by: Pavel Shishkin <pavel.shishkin@jetbrains.com> Moved from: androidx/androidx@faae2fb
fixes JetBrains/compose-multiplatform#3147 there is a bug on all platforms related to incorrect `IrTypeParameterSymbol` remapping during function body transformation because of `copyWithNewTypeParams` is called on function body directly, it doesn't accumulate typeparam symbols mapping (located in signature), which leads to preserving old symbols during body transformation Test: tested against Compose Multiplatform testsuite Change-Id: If813824a3387e78910670174bd6aabe7d13e2d43 ( https://android-review.googlesource.com/q/If813824a3387e78910670174bd6aabe7d13e2d43 ) Signed-off-by: Pavel Shishkin <pavel.shishkin@jetbrains.com> Moved from: androidx/androidx@faae2fb
fixes JetBrains/compose-multiplatform#3147 there is a bug on all platforms related to incorrect `IrTypeParameterSymbol` remapping during function body transformation because of `copyWithNewTypeParams` is called on function body directly, it doesn't accumulate typeparam symbols mapping (located in signature), which leads to preserving old symbols during body transformation Test: tested against Compose Multiplatform testsuite Change-Id: If813824a3387e78910670174bd6aabe7d13e2d43 Signed-off-by: Pavel Shishkin <pavel.shishkin@jetbrains.com>
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks. |
Describe the bug
Affected platforms
Select one of the platforms below:
Versions
To Reproduce
The text was updated successfully, but these errors were encountered: