You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2020/02/04 18:58:00 UTC
[jira] [Commented] (GROOVY-9382) Inconsistent support for
[Bb]oolean properties
[ https://issues.apache.org/jira/browse/GROOVY-9382?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17030061#comment-17030061 ]
Eric Milles commented on GROOVY-9382:
-------------------------------------
Also, if an explicit "is" method is added, no "get" method is generated.
{code:groovy}
class Pogo {
boolean b = true
boolean isB() { b }
}
def pogo = new Pogo()
println pogo.isB() // prints "true"
println pogo.getB() // throws MissingPropertyException
{code}
> Inconsistent support for [Bb]oolean properties
> ----------------------------------------------
>
> Key: GROOVY-9382
> URL: https://issues.apache.org/jira/browse/GROOVY-9382
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.4.18, 2.5.9, 3.0.0-rc-3
> Reporter: Eric Milles
> Priority: Major
>
> In addition to issues noted in GROOVY-5245 and GROOVY-6097, consider the following:
> {code:groovy}
> class Pogo {
> Boolean b = true
> }
> def pogo = new Pogo()
> println pogo.b // prints "true"
> println pogo.getB() // prints "true"
> println pogo.isB() // throws MissingPropertyException
> {code}
> If {{@TypeChecked}} is added, no STC error for {{pogo.isB()}}. If {{@CompileStatic}} is added, no STC error for {{pogo.isB()}} and exception changes to NoSuchMethodError.
> I'd prefer a Boolean property could be accessed using an "is" method. If the scenario is reversed (class with only {{Boolean isB()}} method), the property expression {{pogo.b}} is supported.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)