1

Assuming this class hierarchy:

class A {}
class B extends class A {}

The following code is not valid in Java:

List<A> list = new ArrayList<B>();

Because ArrayList<B> is not a subtype of List<A>.

However, in groovy the code above does not seem to raise an error. Why is that?

alampada
  • 2,329
  • 1
  • 23
  • 18

1 Answers1

2

Groovy ignores your generics unless you annotate things with @CompileStatic

tim_yates
  • 167,322
  • 27
  • 342
  • 338