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

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

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment