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

Type inference on lists

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0-rc-1
    • 2.0-rc-3
    • Static Type Checker
    • None

    Description

      @TypeChecked
      class StaticGroovy2 {
      
          def bar() {
      
              def foo = [new Date(), 1, new C()]
              foo.add( 2 ) // Compiles
              foo.add( new Date() )
              foo.add( new C() )
      
              foo = [new Date(), 1]
              foo.add( 2 ) // Does not compile
          }
      }
      class C{
      }
      

      This code fails to compile on the last line foo.add(2) with the error:
      Groovy:[Static type checking] - Cannot find matching method
      java.util.List#add(int)

      Attachments

        Activity

          People

            melix C├ędric Champeau
            rgarcia Renato Garcia
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: