[
https://issues.apache.org/jira/browse/GROOVY-10909?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17679180#comment-17679180
]
Eric Milles edited comment on GROOVY-10909 at 1/20/23 3:17 PM:
---------------------------------------------------------------
https://github.com/apache/groovy/commit/89de534b77e2321d46e6a9821628331693c7aae2
https://github.com/apache/groovy/commit/d4d3ccf3fd19d5d2fa6fb9fd653af360379be8cb
was (Author: emilles):
https://github.com/apache/groovy/commit/89de534b77e2321d46e6a9821628331693c7aae2
> bytecode for in, !in, !() and ?:
> --------------------------------
>
> Key: GROOVY-10909
> URL: https://issues.apache.org/jira/browse/GROOVY-10909
> Project: Groovy
> Issue Type: Bug
> Components: bytecode, Compiler, Static compilation
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Minor
> Labels: bytecode
>
> Consider the following:
> {code:groovy}
> List getList() { ['xx'] }
> @groovy.transform.CompileStatic
> void test(object) {
> def others = [], strings = []
> if (object in list) { // 4 of 8 branches missed
> strings << object
> }
> if (!(object in list)) { // 4 of 10 branched missed
> others << object
> }
> println others
> println strings
> }
> test(null)
> test('xx')
> test([''])
> {code}
> When unit testing, I noticed 4 of 10 branches missed for "if (!(item in
> list)) ...". When compiled and executed dynamically, it shows 2 of 2
> branches covered (safe call to "list.isCase(item)").
> Static compilation transforms "item in list" into "list == null ? item ==
> null : list.isCase(item)". This is certainly where all the branches are
> coming from.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)