I discovered in a production code a casting from List<List<Integer>> to List<Integer> which does not make any sense, but it's working without any problem being raised, so I wrote a quick test to check it out and to my surprise a List<List<Object>> can behave like a List<Object>
static void main(String[] args) {
List<List<Integer>> list = []
list.add(1)
println(list.get(0))
println(list.get(0).getClass())
}
the output is:
1
class java.lang.Integer
I understand that we can define lists containing values of heterogeneous types like def heterogeneous = [1, "a", true], but in the example above the static typing clearly indicates that it should be List<List<Integer>>
Any explanation of the weird behavior ?