[
https://issues.apache.org/jira/browse/GROOVY-11111?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17737111#comment-17737111
]
Jochen Theodorou commented on GROOVY-11111:
-------------------------------------------
{code:Java}
class A {
void foo(){}
}
{code}
the MethodNode for foo will return true for isDefault(), as it is a public
method with a declaring class. It being a interface or not plays no role
because Optional.of(false).isPresent() will still return true.
> MethodNode isDefault check not correct
> --------------------------------------
>
> Key: GROOVY-11111
> URL: https://issues.apache.org/jira/browse/GROOVY-11111
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Reporter: Jochen Theodorou
> Priority: Major
>
> {code:Java}
> public boolean isDefault() {
> return (modifiers & (ACC_ABSTRACT | ACC_PUBLIC | ACC_STATIC)) ==
> ACC_PUBLIC &&
>
> Optional.ofNullable(getDeclaringClass()).filter(ClassNode::isInterface).isPresent();
> }
> {code}
> 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)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)