Fixed
Status Update
Comments
sj...@google.com <sj...@google.com>
sj...@google.com <sj...@google.com>
ap...@google.com <ap...@google.com> #2
Could you look into it @christofferqa?
The issue is with this class:
class MySpi : Spi {
@Volatile
private var myApi: Api? = null
// Incorrectly rewritten to return null;
override fun createApi(): Api {
return myApi ?: synchronized(this) {
myApi ?: MyApi().also { myApi = it }
}
}
}
The error seems to be that the ArgumentPropagator believes that the fieldState of myApi is ExactDynamicType(@NotNull MyApi)
while it should be ExactDynamicType(@Nullable MyApi)
It then removes the first branch (assuming myApi is not null):
return myApi ?: synchronized(this) {
myApi ?: MyApi().also { myApi = it }
}
is rewritten into:
return myApi
And then it eventually concludes that myApi is always null, replacing the code by
return null
The ArgumentPropagatorCodeScanner analyzes the assignment myApi = it
and correctly set join the state to ExactDynamicType(@NotNull MyApi)
However the ArgumentPropagator fails to understand that myApi
can be read before being written in the method, relying on the default null value, so it fails to join null
to the dynamic type.
Description
The following 3 lint issue(s) are suppressed in
src/main/java/androidx/recyclerview/widget/SortedList.java
. Please remove these suppressions inrecyclerview/recyclerview/lint-baseline.xml
and address the associated issues.