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

Type checker doesn't recognize explicit map constructor

    XMLWordPrintableJSON

Details

    Description

      If a class defines a constructor which takes a map as argument, then the type checker doesn't recognize it and will think that constructor calls with maps are the default groovy map-style constructor.

      example:

      class Foo {
         String message
         Foo(Map map) {
            message = map.msg
         }
      }
      def foo = new Foo(msg: 'bar')
      assert foo.message == 'bar'
      

      Fails with:

      [Static type checking] - No such property: msg for class: Foo
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: