Skip to content

AssistedFactory generation fails under IC #707

@andreaswaltenberger

Description

@andreaswaltenberger

Starting with Anvil 2.4.5 (and probably more importantly Kotlin 1.8.20) the AssistedFactory generation does not happen anymore after a change with incremental compilation.

I have a repro case available here: main...andreaswaltenberger:anvil:repro/assisted_factory

On the first build everything works fine, but when we remove the comments around @Assisted("mom") mother: String in the constructor and the Factory we run into issues when doing an incremental build.
It seems the Anvil compiler is not correctly pick up the change and no longer generates a new/adapted class - it is just missing which then fails kapt/Dagger with:

import com.squareup.anvil.sample.child.Child_Factory_Impl;
                                      ^
symbol:   class Child_Factory_Impl
location: package com.squareup.anvil.sample.child

When rerunning the build with ./gradlew :sample:app:assembleDebug --rerun-tasks everything is compiled correctly again.

I'm not 100% sure this is an Anvil issue or coming from the change in the Kotlin compiler with the new optimisations turned on by default (kapt.use.jvm.ir=true or kotlin.incremental.useClasspathSnapshot=true).

Any ideas what could be going on? Happy to help with additional information if needed, thanks 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions