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

instanceof with || inserts wrong cast

    XMLWordPrintableJSON

Details

    Description

      @groovy.transform.CompileStatic
      def foo(a) {
          if (a instanceof Integer || a instanceof Double) {
              a.floatValue() // expected: cast to Number; actual: cast to Integer
          }
      }
      
      println foo(1d).class // CCE: java.lang.Double cannot be cast to java.lang.Integer
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              daniilo Daniil Ovchinnikov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: