Shishkin Pavel 9 months ago committed by GitHub
parent
commit
d99cf154e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 34
      compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/lib/src/commonMain/kotlin/Dependencies.kt
  2. 51
      compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CollectionOfComposablesTests.kt

34
compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/lib/src/commonMain/kotlin/Dependencies.kt

@ -1,4 +1,6 @@
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import com.example.common.TextLeafNode
import kotlin.jvm.JvmInline
interface ComposableContent { interface ComposableContent {
@ -14,3 +16,35 @@ interface CollectionOfComposable {
fun iterator(): Iterator<@Composable () -> Unit> fun iterator(): Iterator<@Composable () -> Unit>
} }
interface DefaultComposableContent {
@Composable
@Suppress("ABSTRACT_COMPOSABLE_DEFAULT_PARAMETER_VALUE")
fun ComposableContent(
any: String = "any" // default value is required to reproduce
) {
TextLeafNode("DefaultComposableContent - $any")
}
}
abstract class AbstractGreeter {
@Composable
protected abstract fun Greeting()
@Composable
fun Hi() {
Greeting()
}
}
class Greeter(val target: String) : AbstractGreeter() {
@Composable
override fun Greeting() {
TextLeafNode("Hello, $target!")
}
}
@JvmInline
value class ValClass(val key: Int) {
constructor(a: Int, b: Int) : this(a + b)
}

51
compose/integrations/composable-test-cases/testcases/inheritance/composableInterface/main/src/commonTest/kotlin/CollectionOfComposablesTests.kt

@ -1,3 +1,4 @@
import androidx.compose.runtime.Composable
import com.example.common.TextContainerNode import com.example.common.TextContainerNode
import com.example.common.TextLeafNode import com.example.common.TextLeafNode
import com.example.common.composeText import com.example.common.composeText
@ -37,4 +38,54 @@ class CollectionOfComposablesTests {
actual = root.dump() actual = root.dump()
) )
} }
/** Default args for overridden composable produces corrupted function definitions
* https://github.com/JetBrains/compose-multiplatform/issues/3318
*/
@Test
fun testDefaultArgsForOverridden() = runTest {
class Impl : DefaultComposableContent
val root = composeText {
Impl().ComposableContent()
} }
assertEquals(
expected = "root:{DefaultComposableContent - any}",
actual = root.dump()
)
}
/** Override a protected @Composable method leads to Compilation Failed on iOS target
* https://github.com/JetBrains/compose-multiplatform/issues/4055
*/
@Test
fun testOverrideProtected() = runTest {
val root = composeText {
Greeter("Bob").Hi()
}
assertEquals(
expected = "root:{Hello, Bob!}",
actual = root.dump()
)
}
/** Default params for value type defined in separate module may result in compilation failure on iOS
* https://github.com/JetBrains/compose-multiplatform/issues/3643
*/
@Test
fun testDefaultParamValueClass() = runTest {
@Composable
fun test(qualifiers: ValClass = ValClass(123)): String = "${qualifiers.key}"
val root = composeText { TextLeafNode(test()) }
assertEquals(
expected = "root:{123}",
actual = root.dump()
)
}
}

Loading…
Cancel
Save