Vampire
05/09/2022, 6:10 PMfun Provider<out Task>.generateChecksums(destination: Directory? = null) {
get().generateChecksums(destination)
}
fun Task.generateChecksums(destination: Directory? = null) {
}
fun FileSystemLocation.generateChecksums(destination: Directory? = null) {
}
somehow so that the first one can work for both Task
or FileSystemLocation
?
Just adding another method does not work of course as both would have the same type-erased form unless I call it differently.nkiesel
05/09/2022, 6:52 PMTask
and FileSystem
implement?Vampire
05/09/2022, 7:15 PMfun Provider<out Any>.generateChecksums(destination: Directory? = null) {
when (val value = get()) {
is Task -> value.generateChecksums(destination)
is FileSystemLocation -> value.generateChecksums(destination)
else -> error("Unsupported Type")
}
}
but that's bad of course due to the method being callable on all providers.
I hoped there is maybe some way using implicit union types.ephemient
05/09/2022, 7:55 PM@JvmName("generateChecksumsTaskProvider")
public fun Provider<out Task>.generateChecksums()
@JvmName("generateChecksumsFileSystemLocationProvider")
public fun Provider<out FileSystemLocation>.generateChecksums()
will both appear as .generateChecksums()
to Kotlin codeVampire
05/09/2022, 8:00 PMephemient
05/09/2022, 8:56 PMTaskProvider<out Task>
wouldn't have any JVM signature conflictsVampire
05/10/2022, 7:46 AMProvider<out Task>
. Besides that there are 5 more types to cover.ephemient
05/10/2022, 8:03 AMProvider<out Task>
when tasks.register()
gives you a more specific subtype?Vampire
05/10/2022, 8:06 AM