Arkadii Ivanov
05/24/2021, 10:57 PMState
interface have out T
and not just T
? Like State<out T> { ... }
Arkadii Ivanov
05/25/2021, 11:17 AMlouiscad
05/26/2021, 12:03 PMArkadii Ivanov
05/26/2021, 12:05 PMZach Klippenstein (he/him) [MOD]
05/26/2021, 4:59 PMZach Klippenstein (he/him) [MOD]
05/26/2021, 4:59 PMAdam Powell
05/26/2021, 5:27 PMAdam Powell
05/26/2021, 6:13 PMAdam Powell
05/26/2021, 6:14 PMState<T>
objects as a parameter to things, which is where this starts to become handyArkadii Ivanov
05/26/2021, 6:15 PMArkadii Ivanov
05/26/2021, 6:31 PMAdam Powell
05/26/2021, 7:52 PM@BuilderInference
of produceState
and friendslouiscad
05/26/2021, 7:54 PMbuildList
from stlib but messes with produceState
?Adam Powell
05/26/2021, 7:56 PMproduceState
accepts an initial value and if you use a sealed class like with the common Result<T>
type patterns it ends up inferring the more specific type from that.Adam Powell
05/26/2021, 7:56 PMAdam Powell
05/26/2021, 7:57 PMe: $SUPPORT/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/sideeffects/SideEffects.kt: (220, 40): Type mismatch: inferred type is Result.Error but Result.Loading was expected
e: $SUPPORT/compose/integration-tests/docs-snippets/src/main/java/androidx/compose/integration/docs/sideeffects/SideEffects.kt: (222, 20): Type mismatch: inferred type is Result.Success<Image> but Result.Loading was expected
Adam Powell
05/26/2021, 7:58 PMlouiscad
05/26/2021, 8:00 PMout
variance. Otherwise, I think it'll keep coming up on the long term.Adam Powell
05/26/2021, 8:01 PMproduceState<Result<Image>>
or upcast the initial value produceState(initialValue = Result.Loading as Result<Image>,
Arkadii Ivanov
05/26/2021, 8:08 PMAdam Powell
05/26/2021, 8:10 PMArkadii Ivanov
05/26/2021, 8:15 PMArkadii Ivanov
05/26/2021, 8:20 PMArkadii Ivanov
05/26/2021, 8:24 PM@BuilderInference
should ideally work here, but looks like it works only for methods, not for properties. If ProduceStateScope
had fun setValue
, then using this method would help with the inference. But since we are using value = x
, then it does not work, and so the annotation looks even useless.Arkadii Ivanov
05/26/2021, 8:25 PMZach Klippenstein (he/him) [MOD]
05/26/2021, 8:29 PMAdam Powell
05/26/2021, 8:34 PMAdam Powell
05/26/2021, 8:34 PMAdam Powell
05/26/2021, 8:35 PMArkadii Ivanov
05/26/2021, 8:38 PMState<out T>
API looks more correct and more flexible, the change is binary compatible, but is not source compatible. So some compilations will be broken, but easy to fix.Adam Powell
05/26/2021, 10:26 PMlouiscad
05/27/2021, 6:58 AM