Groovy Generics failure

后端 未结 1 570
难免孤独
难免孤独 2020-12-20 12:22

Besides groovy is way more dynamic then java...

Why is this a compile time error in groovy (unexpected token <):

interface A {
     &         


        
相关标签:
1条回答
  • 2020-12-20 12:46

    The Groovy parser does not handle method signatures beginning with Generic information...

    It parses if you add the public modifier:

    interface A {
      public <T> T getByClass( Class<T> clazz )
    }
    

    Though I don't believe you'll gain any type checking at compile time for adding this annotation

    0 讨论(0)
提交回复
热议问题