From 41a6d3d3c7680f119ec9d2b4cb6d3934f051a6a7 Mon Sep 17 00:00:00 2001 From: Pavel Shishkin Date: Fri, 19 Apr 2024 17:40:19 +0200 Subject: [PATCH] Update compose compiler version to 1.5.10.2 (#4652) version bump & test added for reified generic in composable functions Fixes #3147 --- .../composable-test-cases/gradle.properties | 6 +-- .../kotlin/CollectionOfComposablesTests.kt | 47 +++++++++++++++++-- .../compose/ComposeCompilerCompatibility.kt | 2 +- gradle-plugins/gradle.properties | 2 +- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/compose/integrations/composable-test-cases/gradle.properties b/compose/integrations/composable-test-cases/gradle.properties index 368c2060b8..919ee0d68e 100644 --- a/compose/integrations/composable-test-cases/gradle.properties +++ b/compose/integrations/composable-test-cases/gradle.properties @@ -1,11 +1,11 @@ org.gradle.jvmargs=-Xmx4096M -XX:MaxMetaspaceSize=512m kotlin.code.style=official android.useAndroidX=true -kotlin.version=1.9.22 +kotlin.version=1.9.23 agp.version=7.3.0 # a version of compose libraries. In this project the only dependency is compose-runtime. -compose.version=1.6.0-rc03 +compose.version=1.6.1 # a group id for compose-runtime. Keep it as a parameter to easily change it on CI. compose.runtime.groupId=org.jetbrains.compose.runtime @@ -13,7 +13,7 @@ kotlinx.coroutines.version=1.8.0 #empty by default - a default version will be used #compose.kotlinCompilerPluginVersion=23.12.18 -compose.kotlinCompilerPluginVersion=1.5.10.1 +compose.kotlinCompilerPluginVersion=1.5.10.2 # default|failingJs - see enum class CasesToRun tests.casesToRun=default diff --git a/compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CollectionOfComposablesTests.kt b/compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CollectionOfComposablesTests.kt index 2bf316a4b5..e23d406c4f 100644 --- a/compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CollectionOfComposablesTests.kt +++ b/compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CollectionOfComposablesTests.kt @@ -4,6 +4,7 @@ import com.example.common.TextLeafNode import com.example.common.composeText import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest +import kotlin.reflect.KClass import kotlin.test.Test import kotlin.test.assertEquals @@ -45,7 +46,7 @@ class CollectionOfComposablesTests { @Test fun testDefaultArgsForOverridden() = runTest { class Impl : DefaultComposableContent - + val root = composeText { Impl().ComposableContent() } @@ -101,7 +102,8 @@ class CollectionOfComposablesTests { val f: List<@Composable () -> Unit>, ) - val composables: List<@Composable () -> Unit> = listOf(@Composable { TextLeafNode("a") }, @Composable { TextLeafNode("b") }) + val composables: List<@Composable () -> Unit> = + listOf(@Composable { TextLeafNode("a") }, @Composable { TextLeafNode("b") }) val single = SingleNested(composables) val singleRoot = composeText { @@ -124,6 +126,45 @@ class CollectionOfComposablesTests { ) assertEquals(singleRoot.dump(), doubleRoot.dump()) } -} + interface ViewModel { + @Composable + fun content() + } + + class ViewModelA : ViewModel { + @Composable + override fun content() { + TextLeafNode("a") + } + } + + fun get(klass: KClass, viewModelBlock: () -> T): T { + if (klass.toString().contains("asdf")) { + throw Exception("AsdfASDFASDF") + } + return viewModelBlock() + } + + @Composable + inline fun getReified( + noinline viewModelBlock: () -> T + ): T = get(T::class, viewModelBlock) + + /** Composable functions with `reified` generic types without proper symbol remapping for + * `IrTypeParameterSymbol` (inside 'T::class' / `IrClassReference`) + * https://github.com/JetBrains/compose-multiplatform/issues/3147 + */ + @Test + fun testReifiedGenericComposable() = runTest { + val root = composeText { + val vm = getReified { ViewModelA() } + vm.content() + } + assertEquals( + expected = "root:{a}", + actual = root.dump() + ) + } +} diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt index 8cc55d0620..5855fe671d 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerCompatibility.kt @@ -23,7 +23,7 @@ internal object ComposeCompilerCompatibility { "1.9.20" to "1.5.3", "1.9.21" to "1.5.4", "1.9.22" to "1.5.8.1", - "1.9.23" to "1.5.10.1", + "1.9.23" to "1.5.10.2", "2.0.0-Beta1" to "1.5.4-dev1-kt2.0.0-Beta1", "2.0.0-Beta4" to "1.5.9-kt-2.0.0-Beta4", "2.0.0-Beta5" to "1.5.11-kt-2.0.0-Beta5", diff --git a/gradle-plugins/gradle.properties b/gradle-plugins/gradle.properties index 0e95aee298..a8214f8831 100644 --- a/gradle-plugins/gradle.properties +++ b/gradle-plugins/gradle.properties @@ -10,7 +10,7 @@ dev.junit.parallel=false # Default version of Compose Libraries used by Gradle plugin compose.version=1.6.10-dev1590 # The latest version of Compose Compiler used by Gradle plugin. Used only in tests/CI. -compose.tests.compiler.version=1.5.10.1 +compose.tests.compiler.version=1.5.10.2 # The latest version of Kotlin compatible with compose.tests.compiler.version. Used only in tests/CI. compose.tests.compiler.compatible.kotlin.version=1.9.23 # The latest version of Kotlin compatible with compose.tests.compiler.version for JS target. Used only on CI.