Status Update
Comments
jo...@google.com <jo...@google.com>
lp...@google.com <lp...@google.com>
lp...@google.com <lp...@google.com> #2
I looked into this: it seems to be specific to kotlin 2.0.0, so I guess this is K2 UAST? What I noticed:
For:
value = emailRepository.getEmails()
In 1.9, the value expression resolves to setValue
- but in 2.0, this resolves to getValue
, which seems like a bug, since the getValue operator fun shouldn't be invoked here. Jinseong, can you confirm if this change seems intended?
js...@google.com <js...@google.com> #3
Thank you for looking into this first. This saved all of our time!
Kotlin version 2.0.0
You're right; this is K2 UAST, since we sync on language version now.
Re: setValue
v.s. getValue
for value
reference in lhs,
Thanks for the pointer and investigation. This is probably one and only different behavior between K1 v.s. K2 UAST. Note that it's sort of undefined behavior if you use name reference and resolve it while its context is determined by enclosing operator. For example,
value += ...
what should we do for resolution of value
? It's technically:
value = value + ...
and the getter should be invoked first. K1 UAST tended to return setter first, whereas K2 UAST returns getter first; and both go directly to compiler's resolution results, i.e., no extra handling at UAST level. I decided to let it be, while working on
Looking at ProduceStateDetector
, in this case, relying on the resolution on name reference is subject to change, and it should rather use operator resolution. I can send out a quick fix.
ap...@google.com <ap...@google.com> #4
Branch: androidx-main
commit c103849f4a044bcaa002a9714fa3b826129ef4eb
Author: Jinseong Jeon <jsjeon@google.com>
Date: Sun Jun 30 10:33:33 2024
Examine binary operator instead of name reference
That way, we can naturally avoid checking a case like
```
val foo = value
```
by looking at lhs of operators.
Also, we can detect a case like
```
value += "additional value"
```
as well, whose resolution is subject to change between K1 and K2 UAST.
Multi resolution allows us to examine all possible resolution results.
Bug: 349411310
Test: unit test modified, tested w/ K2 UAST
Change-Id: I4a984ac564d1b0295a7b5068ba0ce784b2056e65
M compose/runtime/runtime-lint/src/main/java/androidx/compose/runtime/lint/ProduceStateDetector.kt
M compose/runtime/runtime-lint/src/test/java/androidx/compose/runtime/lint/ProduceStateDetectorTest.kt
js...@google.com <js...@google.com>
za...@gmail.com <za...@gmail.com> #5
I'm still reproducing this with lint 8.7.0-alpha03 and compose-runtime lint 1.7.0-beta06, I don't think this is fixed
Example (albeit somewhat more complex)
val audioPlayState by
produceState(AudioPlayState.default(), key1 = file) {
playbackStateUseCase(file)
.mapNotNull { if (sliderValue.userSeek) it.mapUserSeek(sliderValue.progress) else it }
.filterNotNull()
.collectLatest {
sliderValue = SliderValueChange(it.progress)
valueRange = 0f..max(1f, it.duration)
this.value = it
}
}
js...@google.com <js...@google.com> #6
I marked this fixed so that the bot can chime in and said which version contains the fix. I expect it to be 8.7.0-alpha04 (cut yesterday). Stay tuned; I have a repro project, so I'll try that myself as well.
js...@google.com <js...@google.com> #7
^ oops, sorry, wrong buganizer iteam :p I meant
js...@google.com <js...@google.com> #10
Louis, can we cherry-pick that to compose-runtime 1.7.0 (if it's still in beta)?
cl...@google.com <cl...@google.com> #11
by the time this change landed, Compose had already branched 1.7 off to a beta branch and so this landed in 1.8 ToT.
If Louis thinks this is safe to CP to 1.7 we can consider that, it looks like quite a significant change to me.
If not, the moment we get to RC with 1.7 (some ongoing issues are keeping us in beta) we will then start publishing 1.8 alpha artifacts
lp...@google.com <lp...@google.com> #12
I don't think there is much risk here, but at the same time I don't think it is that common / meets the bar for a cherry pick. Waiting for 1.8 seems reasonable to me
za...@gmail.com <za...@gmail.com> #13
It means anyone on K2 has to disable this lint check until 1.8, and for many that means probably not until early next year. If it's low risk, i think it'd be better to pull it in. Otherwise suspect most people will just disable and never think of it again
lp...@google.com <lp...@google.com> #14
Kicking off the cherry pick process
za...@gmail.com <za...@gmail.com> #15
Thanks!
b9...@gmail.com <b9...@gmail.com> #16
sj...@gmail.com <sj...@gmail.com> #18
Seeing same problem here since updating to AGP 8.6.0
. Kotlin 2.0.20
and Chris Banes' 2024.08.00-alpha02
, which 1.7.0-rc01
.
qi...@gmail.com <qi...@gmail.com> #19
lu...@googlemail.com <lu...@googlemail.com> #20
Is this really fixed? I still see the issue with AGP 8.6.1
, Compose-BOM 2024.09.03
, even if using compose-runtime 1.8.0-alpha03
lp...@google.com <lp...@google.com> #22
There was an issue here that was fixed, but it looks like there is a separate issue when using keys: please follow
Description
Jetpack Compose version:
1.6.8
Jetpack Compose component(s) used:
androidx.compose.runtime
Android Studio Build: N/A
Kotlin version:
2.0.0
Steps to Reproduce or Code Sample to Reproduce:
The following snippet is linted as an error for not assigning the value in lint
8.6.0-alpha07
, agp8.5.0
, and compose runtime1.6.8
.Reproducer (suppressed) can be found here:https://github.com/slackhq/circuit/pull/1480
Stack trace (if applicable):