Groovy 命名参数编译因@CompileStatic而失败-如何修复?

Groovy 命名参数编译因@CompileStatic而失败-如何修复?,groovy,compile-static,Groovy,Compile Static,这段代码在动态类型Groovy中工作得非常好 buildDirectory.traverse(type: FILES, nameFilter: ~/dependency-updates-report.xml/) { reports << it } Map参数是这里的问题吗 EDITbuildDirectory的类型为java.io.File,并且是注入的。如果是那样的静态编译,则需要显式转换为: buildDirectory.traverse([type: FILES, n

这段代码在动态类型Groovy中工作得非常好

buildDirectory.traverse(type: FILES, nameFilter: ~/dependency-updates-report.xml/) {
    reports << it
}
Map
参数是这里的问题吗


EDITbuildDirectory的类型为
java.io.File
,并且是注入的。

如果是那样的静态编译,则需要显式转换为:

buildDirectory.traverse([type: FILES, nameFilter: ~/dependency-updates-report.xml/] as Map) {
    reports << it
}
而Groovy惯用映射创建创建类型为

Map<String, Object>
LinkedHashMap<String, Serializable>
LinkedHashMap

这个
Serializable
在这里是一个问题,因为它不是
java.lang.Object
的子类。您能显示完整的错误消息吗?以及如何声明
buildDirectory
LinkedHashMap<String, Serializable>