Browse Source

web: add compiler test case `Composable With Typed Default Values` (#1231)

Co-authored-by: Oleksandr Karpovich <oleksandr.karpovich@jetbrains.com>
pull/1312/head
Oleksandr Karpovich 3 years ago committed by GitHub
parent
commit
0f1d191b93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 43
      web/compose-compiler-integration/testcases/failing/ComposableWithTypedDefaultValues.kt

43
web/compose-compiler-integration/testcases/failing/ComposableWithTypedDefaultValues.kt

@ -0,0 +1,43 @@
// @Module:Main
import androidx.compose.runtime.Composable
import androidx.compose.runtime.currentComposer
import androidx.compose.runtime.Composer
fun main() {
callComposable {
ComposableWithTypedDefaultValue<String>({})
}
}
fun callComposable(content: @Composable () -> Unit) {
val c = content
}
// @Module:Lib
import androidx.compose.runtime.Composable
sealed class NullableWrapper<T> {
companion object {
fun <T> of(value: T?): NullableWrapper<T> =
if (value != null) {
NonNullWrapper(value)
} else {
NullWrapper()
}
}
abstract val value: T?
}
class NonNullWrapper<T>(override val value: T) : NullableWrapper<T>()
class NullWrapper<T> : NullableWrapper<T>() {
override val value: T? get() = null
}
@Composable // https://github.com/JetBrains/compose-jb/issues/1226
fun <T> ComposableWithTypedDefaultValue(
onChange: (NullableWrapper<T>) -> Unit,
valueWrapper: NullableWrapper<T> = NullWrapper()
) {}
Loading…
Cancel
Save