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

SC: map access different for parameter and local variable of same type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.21, 4.0.21
    • 3.0.22, 4.0.22
    • Static compilation
    • None

    Description

      Consider the following:

      class C implements Map<String,String> {
          @Delegate Map<String,String> impl = [:]
      }
      def map = new C()
      assert map.entry == null
      assert map.empty == null
      assert map.class == null
      assert map.metaClass == null
      
      def test(C map) {
          assert map.entry == null
          assert map.empty == null
          assert map.class == null
          assert map.metaClass == null
      }
      test(new C())
      

      The method-based test fails with "class" returning the map class. Something is different for local variable and parameter property expressions.

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: