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

wasted work in "ClassCompletionVerifier.checkMethodForWeakerAccessPrivileges"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.5
    • 2.0.6, 2.1.0-beta-1
    • None
    • None
    • Patch

    Description

      The problem appears in version 1.8.4 and in revision 4cf5263.. I
      attached a one-line patch (patch.diff) that fixes it. I will also
      post (in the "Comments" section) the URL for the github pull request.

      The entire work performed in method
      "ClassCompletionVerifier.checkMethodForWeakerAccessPrivileges"
      produces no result when the parameter "MethodNode mn" represents a
      public method, i.e., when "mn.isPublic()" is "true". This condition
      can be evaluated right at the beginning of the
      "checkMethodForWeakerAccessPrivileges" method body, thus avoiding the
      entire method execution.

      We can have this fast exist because the method
      "checkMethodForWeakerAccessPrivileges" produces results only when this
      condition (in the method code):

      if ((mn.isPrivate() && !superMethod.isPrivate()) ||
              (mn.isProtected() && superMethod.isPublic()))
      

      evaluates to "true", which does not happen when "mn.isPublic()" is
      "true" (i.e., when "!mn.isPrivate() && !mn.isProtected()" is "true").

      I attached a second one-line patch (patchTwoCond.diff) where I use the
      condition "!mn.isPrivate() && !mn.isProtected()" instead of
      "mn.isPublic()", in case you prefer the longer condition.

      Attachments

        1. patch.diff
          0.7 kB
        2. patchTwoCond.diff
          0.8 kB

        Activity

          People

            blackdrag Jochen Theodorou
            adriannistor Adrian Nistor
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: