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

Type coercion ambiguity int -> (long, double)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-5
    • 1.0
    • None
    • None
    • Java 1.5, Win XP

    Description

      with JSR 05 I get an error when calling:
      println new java.text.DecimalFormat().format(23)

      groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.text.DecimalFormat#format.
      Cannot resolve which method to invoke for

      {class java.lang.Integer}

      due to overlapping prototypes between:

      {long} {double}

      I have the workaround to call
      println new java.text.DecimalFormat().format(23 as long)
      but I don't like this very much.
      An int fits perfectly in a long, so there shouldn't be any disambiguity
      between long, double.

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            tof Christof Vollrath
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: