groovy
  1. groovy
  2. GROOVY-3296

Support for primitive types in categories

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.6-rc-1
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
      None
    • Testcase included:
      yes
    • Number of attachments :
      0

      Description

      Currently methods that take primitive types cannot be used through categories. While it might not be an issue for new classes created with the future category use in mind, existing classes frequently cannot be changed from using primitive to wrapper types just to be usable as categories.

      For example the Math class is now not very useful to be used as a Category due to this limitation.
      double number = 10.0
      println Math.log(number)
      use(Math)

      { println number.log() }

      This code will throw with "Caught: groovy.lang.MissingMethodException: No signature of method: java.lang.Double.log() is applicable for argument types: () values: {}"

        Activity

        Hide
        blackdrag blackdrag added a comment -

        the code for categories would have to ensure that for example double and Double are handled as one

        Show
        blackdrag blackdrag added a comment - the code for categories would have to ensure that for example double and Double are handled as one
        Hide
        Pascal Schumacher added a comment -

        Is this something for Groovy 3?

        Show
        Pascal Schumacher added a comment - Is this something for Groovy 3?

          People

          • Assignee:
            Unassigned
            Reporter:
            Vaclav Pech
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: