title: Chance for this hole in Groovy staic typing to be fixed
body: <p>When I run the following Groovy snippet, it prints ",a,b,c" as expected:</p>
  
  <pre><code>@CompileStatic
  public static void main(String[] args) {
      def inList = ["a", "b", "c"]
      def outList = inList.inject("", { a, b -&gt; a + "," + b })
      println(outList)
  }
  </code></pre>
  
  <p>Now I change the first parameter in inject from an empty string to the number 0:</p>
  
  <pre><code>@CompileStatic
  public static void main(String[] args) {
      def inList = ["a", "b", "c"]
      def outList = inList.inject(0, { a, b -&gt; a + "," + b })
      println(outList)
  }
  </code></pre>
  
  <p>This won't work an produces an exception "Cannot cast object '0,a' with class 'java.lang.String' to class 'java.lang.Number'". Problem is that the compiler did not complain. I tried this in Scala and Kotlin (where inject is called fold) an the respective compiler complains about the mismatch as expected. Also the counterpart in Java8 does not compile (it says found int, required: java.lang.String):</p>
  
  <pre><code>List&lt;String&gt; list = Arrays.asList("a", "b", "c");
  Object obj = list.stream().reduce(0, (x, y) -&gt; x + y);
  System.out.println(obj);
  </code></pre>
  
  <p>Question is now whether this can be fixed in Groovy or whether this is a a general problem because of static typing being introduced later into the language.</p>