HI, I'm an jvm `anvil` user. Now I want to experi...
# squarelibraries
u
HI, I'm an jvm
anvil
user. Now I want to experiment with KMP. I want to keep
@Inject
and
@ContributesBinding..
in common - and expect-actual them to typealiases of the jvm libs (and therefore have anvil/dagger take effect only on jvm)
@Inject
is easy enough
Copy code
@Target(
    FUNCTION,
    PROPERTY_GETTER,
    PROPERTY_SETTER,
    CONSTRUCTOR,
    FIELD
)
@Retention(RUNTIME)
@MustBeDocumented
expect annotation class Inject()
Copy code
actual typealias Inject = javax.inject.Inject
but I'm having trouble with
@ContributesBinding
because of all the params. See the full issue in thread
Copy code
expect enum class ContributesBindingPriority { NORMAL, HIGH, HIGHEST }

@Target(CLASS)
@Retention(RUNTIME)
@Repeatable
expect annotation class ContributesBinding(
    val scope: KClass<*>,
    val boundType: KClass<*> = Unit::class,
    val replaces: Array<KClass<*>> = [],
    @Deprecated("Use the new int-based rank")
    val priority: ContributesBindingPriority = ContributesBindingPriority.NORMAL,
    val ignoreQualifier: Boolean = false,
    // Use the literal default to avoid needing an expect companion
    val rank: Int = Int.MIN_VALUE
)
I simply copy pasted the annotation source & created my own priority enum and then
Copy code
actual typealias ContributesBindingPriority = com.squareup.anvil.annotations.ContributesBinding.Priority
actual typealias ContributesBinding = com.squareup.anvil.annotations.ContributesBinding
but I'm getting
Copy code
e: file:///Users/.../base-di/src/jvmMain/kotlin/foo/bar/di/Shims.jvm.kt:11:1 Parameter 'boundType' has conflicting values in expected and actual annotations.
e: file:///Users/.../base-di/src/jvmMain/kotlin/foo/bar/di/Shims.jvm.kt:11:1 Parameter 'replaces' has conflicting values in expected and actual annotations.
e: file:///Users/.../base-di/src/jvmMain/kotlin/foo/bar/di/Shims.jvm.kt Parameter 'priority' has conflicting values in expected and actual annotations.
e: file:///Users/.../base-di/src/jvmMain/kotlin/foo/bar/di/Shims.jvm.kt Parameter 'ignoreQualifier' has conflicting values in expected and actual annotations.
e: file:///Users/.../base-di/src/jvmMain/kotlin/foo/bar/di/Shims.jvm.kt Parameter 'rank' has conflicting values in expected and actual annotations.
is this idea completely flawed or am I doing it wrong?
am I SOL? only to fork and remove the
Priority
?
remove the defaults from your
expect annotation class
u
OMG, THANK YOU