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,081
  • 1
  • 18
  • 15

1 Answers1

2

Groovy ignores your generics unless you annotate things with @CompileStatic

tim_yates
  • 154,107
  • 23
  • 313
  • 320