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

MethodNode isDefault check not correct

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • None
    • None
    • Compiler
    • None

    Description

          public boolean isDefault() {
              return (modifiers & (ACC_ABSTRACT | ACC_PUBLIC | ACC_STATIC)) == ACC_PUBLIC &&
                  Optional.ofNullable(getDeclaringClass()).filter(ClassNode::isInterface).isPresent();
          }
      

      isPresent gives true if the value represented by the option exists, but not what value it is. Here isPresent would return true even if the class node represents a class and not an interface. While this cannot happen so far unless forced, I still suggest to replace isPresent with orElse(false)

      Attachments

        Activity

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

          People

            Unassigned Unassigned
            blackdrag Jochen Theodorou
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment