Kord-Extensions/kord-extensions

Duplicate class kotlin.internal.OnlyInputTypes found in modules kord-extensions-1.6.0 (com.kotlindiscord.kord.extensions:kord-extensions:1.6.0) and kotlin-stdlib-2.0.0 (org.jetbrains.kotlin:kotlin-stdlib:2.0.0)

Closed this issue · 5 comments

Hi,

In an Android project, if we add the kord-extensions dependency and want to build an apk, the "checkDebugDuplicateClasses" task finds the duplicated class kotlin.internal.OnlyInputTypes :

> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class kotlin.internal.OnlyInputTypes found in modules kord-extensions-1.6.0.jar -> kord-extensions-1.6.0 (com.kotlindiscord.kord.extensions:kord-extensions:1.6.0) and kotlin-stdlib-2.0.0.jar -> kotlin-stdlib-2.0.0 (org.jetbrains.kotlin:kotlin-stdlib:2.0.0)

After looking at the project, I found the duplicated class which is also in the org.jetbrains.kotlin:kotlin-stdlib package which is implemented in these sub-projects.

Is this normal?
Isn't there an alternative to that?

Hey there, thanks for the question!

Yes, this is intentional. This annotation is a Kotlin internal annotation that we make use of in the ChangeSet type, and because it's marked internal, we have to provide our own version of it with the same package for us to be able to use it and have it behave as expected.

This YouTrack issue was submitted about 8 years ago. About 7 years ago, a JetBrains team member stated that they intended to make this annotation public, but, well, this still hasn't happened.

I'm open to alternatives, but the only other approach I'm aware of is a suppression hack from 2021. Have y'all got any ideas?

You could just use @Supress("INVISIBLE_REFERENCE") instead of duplicating the class

That's the suppression hack I talked about - @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")

It makes the code hella messy, but at least it seems to work - I'll push after testing.

I've pushed this ugly-ass code to 1.8.1-SNAPSHOT, and it should be available in 15 minutes or so.

public operator fun <
	@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
	@kotlin.internal.OnlyInputTypes
	T : Any?,
	> set(

	key: KProperty<T>,
	value: Change<T>,
) {
	changes[key] = value
}

I sure wish there was a better way, haha

I usually use file: annotations