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

STC support assignment of primitives to interface types like Comparable and Serializable

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      @groovy.transform.TypeChecked
      void test() {
        Serializable x = 0
        Serializable y = 1.2
        Serializable z = Math.PI
        System.err.println(x.class.name)
        System.err.println(y.class.name)
        System.err.println(z.class.name)
      }
      test()
      

      The BigDecimal literal 1.2 works fine. The other two give an error. Dynamic groovy boxes and completes the assignment.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: