Vampire
07/25/2022, 11:43 AMimport org.gradle.api.Action
inline fun <T> action(crossinline block: T.() -> Unit): Action<T> {
return object : Action<T> {
override fun execute(t: T) {
t.run(block)
}
}
}
But updating Gradle to 7.5 and thus Kotlin to 1.6.10 now gives a compilation error (well warning, but we have -Werror
) about wrong nullability:
w: ...\buildSrc\src\main\kotlin\...\util\SamHelper.kt: (10, 7): Override 'fun execute(t: T): Unit' has incorrect nullability in its signature comparing with overridden 'fun execute(p0: T): Unit'
What is his problem suddenly and how do I mitigate it?Sam
07/25/2022, 11:49 AMType parameter ‘T’ has nullable upper bound, so override has incorrect signature comparing with a base member with NotNull annotation. Please add a non-nullable upper bound (e.g. Any) to the type parameter. See https://kotlinlang.org/docs/generics.html#upper-bounds for more details
Sam
07/25/2022, 11:50 AMinline fun <T: Any> action(crossinline block: T.() -> Unit): Action<T> {
Vampire
07/26/2022, 10:04 AM