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

STC: error message for inaccessible setter is not too helpful

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      class M extends HashMap<String,Number> {
        private void setFoo(foo) { print foo }
      }
      @groovy.transform.CompileStatic
      void test() {
        def map = new M()
        map.foo = 123
        print map.foo
      }
      

      Assignment expression "map.foo = 123" shows error "[Static type checking] - Cannot assign value of type int to variable of type java.lang.Object". Adding cast to Object changes the message to "Cannot assign value of type java.lang.Object to variable of type java.lang.Object".

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: