"Incompatible return type" error when using ReportContainer and TaskReportContainer

I tried to add support for Reporting in my plugin, but I’ve got:

PitestReportsContainerImpl.groovy: -1: The return type of org.gradle.api.NamedDomainObjectSet matching(org.gradle.api.specs.Spec) in org.gradle.api.internal.DefaultNamedDomainObjectSet is incompatible with org.gradle.api.DomainObjectCollection matching(org.gradle.api.specs.Spec) in org.gradle.api.DomainObjectCollection
. At [-1:-1]
@ line -1, column -1.
1 error

I use in my PitestReportsContainer and PitestReportsContainerImpl the same convention as JacocoPlugin (from Gradle 1.10).

The error can be reproduced with:

git clone https://github.com/szpak/gradle-pitest-plugin.git -b reporting-error
cd gradle-pitest-plugin
./gradlew build

@GreadleDevs, could you at least check if the problem is reproducible with attached code?

This error (if not cause by my environment or my mistake) would prevent using ReportContainer by all plugin developers.

This might be a Groovy compiler bug.

Could you try writing your report classes in Java?

It could be related to GROOVY-5418 - fixed in Groovy 1.8.9 (1.8.6 used by Gradle is quite old).

Luckily it works fine with class written in Java. Thanks for a hint.