build.gradle file, task using << notation, intellij warns: "Cannot infer argument type"

If you are willing to disable the Groovy > Assignment Issues > Incompatible type assignments inspection, the warning goes away.


In a highly dynamically typed language such as groovy where names and symbols are resolved in arbitrary ways It would be quite difficult to determine the validity of any statement ahead of time without running the program. even running the program would theoretically not divulge all possible permutations of input that may change the runtime validity of a statement.

I applaud intellij's attempt at this hard problem and can live with a few incorrect syntax warnings here and there.


Untill the IntelliJ bug is fixed, there is a workaround: use doFirst instead of <<.

task hellofun() {
  doFirst {
    [silly:'billy'].each { k, v ->
      println "$k=$v"
    }
  }
}

Thanks for submitting the bug :)