Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5503

Compiler flag for type checking most classes, and TypeUnchecked annotation override

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.1.0-beta-1
    • Compiler
    • None

    Description

      Allow use of a Groovy compiler flag to enable type checking for all classes and methods except for the classes and methods annotated with a @TypeUnchecked annotation (or another antonym of @TypeChecked such as @NotTypeChecked or @RuntimeTypeChecked or @TestInProduction or @YouNeedExtraUnitTestsForThis)

      For large projects with hundreds of classes, where we want type checking on 99% of the code, it would be too much boilerplate to remember to put @TypeChecked annotations on every class. It would also require us to refactor methods containing dynamic code into separate non-type-checked classes just to satisfy the @TypeChecked contract. It would be better to have a compiler flag to reverse the type checking contract so everything is type checked except for the classes and methods that are explicitly marked for allowing dynamic code.

      Discussed with Guillaume Laforge after his talk about Groovy 2.0 at GR8Conf 2012 in Copenhagen. He agreed it would be a good addition for Groovy 2.1, and that I should open a Jira ticket. Another audience member had the same request as well.

      Attachments

        Issue Links

          Activity

            People

              melix Cédric Champeau
              jsondow Joe Sondow
              Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: