I have `tasks.withType(JmhTask::class.java) { }` ...
# announcements
e
I have
tasks.withType(JmhTask::class.java) { }
where
tasks
is a
TaskContainer
type, which extends
interface DomainObjectCollection<T>
DomainObjectCollection<T>::withType
is defined as
<S extends T> DomainObjectCollection<S> withType(Class<S> type, Action<? super S> configureAction)
I'd like to type instead
tasks<JmhTask> { }
, so I wrote:
Copy code
inline operator fun <reified S> TaskContainer.invoke(configureAction: Action<in S>?) = withType(S::class.java, configureAction)
but
withType
is marked red:
Copy code
None of the following functions can be called with the arguments supplied.
withType(Class<TypeVariable(S)!>, Action<in TypeVariable(S)!>)   where S = TypeVariable(S) for    fun <S : Task!> withType(type: Class<S!>, configureAction: Action<in S!>): DomainObjectCollection<S!> defined in org.gradle.api.tasks.TaskContainer
z
You might want to try #C19FD9681
e
thanks but in the meanwhile I found a solution: it was as simple as adding a lower bound
<reified S: Task>