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

Inconsistent numeric range types

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.1
    • 1.8.5, 2.0-beta-2
    • class generator
    • None

    Description

      I would expect that range literal follow the same type promotion rules as arithmetic operations, yet:

      assert (1+10).class == Integer   
      assert (1L+10).class == Long 
      assert (1+10L).class == Long 
      
      assert (1..10).every { it.class == Integer  } 
      assert (1L..10).every { it.class == Long } 
      assert (1..10L).every { it.class == Integer } // <= weird 
      

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            ddimitrov Dimitar Dimitrov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: