[ 
https://issues.apache.org/jira/browse/GROOVY-12072?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King updated GROOVY-12072:
-------------------------------
    Description: 
Static case:
{code:groovy}
import groovy.contracts.*
import static java.lang.Math.max

@groovy.transform.CompileStatic
@Invariant({ max(3, 4) == 4 })
class C {
  @Requires({ max(3, 4) == 4 })
  static int iter(int n) {
    int a = 0
    @Invariant({ max(3, 4) == 4 })
    while (a < n) { a++ }
    return a
  }
}

assert C.iter(4) == 4
{code}

Normal imports:
{code:groovy}
import groovy.contracts.*
import java.lang.Math

@groovy.transform.CompileStatic
@Invariant({ Math.max(3, 4) == 4 })
class C {
  @Requires({ Math.max(3, 4) == 4 })
  static int iter(int n) {
    int a = 0
    @Invariant({ Math.max(3, 4) == 4 })
    while (a < n) { a++ }
    return a
  }
}

assert C.iter(4) == 4
{code}


> groovy-contracts: loop invariant doesn't run static import visitor
> ------------------------------------------------------------------
>
>                 Key: GROOVY-12072
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12072
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>
> Static case:
> {code:groovy}
> import groovy.contracts.*
> import static java.lang.Math.max
> @groovy.transform.CompileStatic
> @Invariant({ max(3, 4) == 4 })
> class C {
>   @Requires({ max(3, 4) == 4 })
>   static int iter(int n) {
>     int a = 0
>     @Invariant({ max(3, 4) == 4 })
>     while (a < n) { a++ }
>     return a
>   }
> }
> assert C.iter(4) == 4
> {code}
> Normal imports:
> {code:groovy}
> import groovy.contracts.*
> import java.lang.Math
> @groovy.transform.CompileStatic
> @Invariant({ Math.max(3, 4) == 4 })
> class C {
>   @Requires({ Math.max(3, 4) == 4 })
>   static int iter(int n) {
>     int a = 0
>     @Invariant({ Math.max(3, 4) == 4 })
>     while (a < n) { a++ }
>     return a
>   }
> }
> assert C.iter(4) == 4
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to