square / anvil

A Kotlin compiler plugin to make dependency injection with Dagger 2 easier.
Apache License 2.0
1.31k stars 80 forks source link

Immediately re-run analysis if cache restoration generated changes #918

Closed RBusarow closed 6 months ago

RBusarow commented 6 months ago

If we make any changes while syncing the local state with our internal cache, that will affect the source files and PSI parsing, but it doesn't affect the state represented by the ModuleDescriptor. In order to get things in sync, we need to return a RetryWithAdditionalRoots.

While doing that analysis, the compiler will also sync its own files -- which means it will delete any .class files that are no longer current.

See discussion here: https://github.com/square/anvil/pull/877#discussion_r1517184297

RBusarow commented 6 months ago

This is nearly impossible to test, outside of logging. I can get kind of close using KCT and previousCompilationResult, but that compilation isn't incremental so its behavior is different.

With that being said, the test in question here passes when these changes are in place.