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

Close a small gap in the EMC DSL for constructors

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.3
    • Fix Version/s: 3.0.0-alpha-4, 2.5.3
    • Component/s: None
    • Labels:
      None

      Description

      In the sample below, the first short-hand (Integer case) is recognised, the second two aren't for constructors even though they are for methods and work if "<init>" is used instead:

      Integer.metaClass {
          constructor = { List l -> l.size() }
      }
      Short.metaClass {
          constructor { List l -> l.size() as short }
      }
      Long.metaClass {
          constructor << { List l -> l.size() as long }
      }
      
      def result = [[] as Short, ['foo'] as Integer, ['bar', 'baz'] as Long]
      assert result.toString() == '[0, 1, 2]'
      assert result*.class == [Short, Integer, Long]
      

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              paulk Paul King
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: