Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Component used: WorkManager Testing
Version used: 2.4.0
Devices/Android versions reproduced on: N/A
TestListenableWorkerBuilder
extension:If using the Hilt Work integration, this code doesn't work. You need to add the
HiltWorkerFactory
to the builder. But since the extension function doesn't include the factory in it's parameters, you need to set it afterwards using the Builder's.setWorkerFactory()
method. At this point, the reified type parameter is lost, and you have to cast the result of thebuild()
method to your worker type, as in the following modified example:If we have to do this cast to use the rest of the builder methods not supported by the extension, it defeats the purpose of the extension function's reification.
Thus, please add the ability to set the worker factory to the extension function, so we can get rid of the cast.