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

Prefer ClassHelper.make(Class) over new ClassNode(Class)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.8-rc-1, 1.9-beta-1
    • None
    • None
    • Patch

    Description

      Following the discussion at http://groovy.329449.n5.nabble.com/Question-about-ClassNode-tp3382159p3382159.html, here's a patch fixing the direct calls to ClassNode(Class). All tests pass but :

      in VariableExpressionTest#testIsDynamicTypedExplicitObject, we have the following code :

              VariableExpression intExpression = new VariableExpression("foo", new ClassNode(Object.class));
              assertFalse(intExpression.isDynamicTyped());
      

      Replacing new ClassNode(Object.class) with ClassHelper.OBJECT_TYPE would cause the test to fail because ClassHelper.OBJECT_TYPE and ClassHelper.DYNAMIC_TYPE share the same reference.

      2d, I had to alter the immutable annotation test because ClassHelper.make includes generic type information where new ClassNode() didn't. It does not change the logic though.

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: