groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Smith (JIRA)" <>
Subject [jira] [Created] (GROOVY-7449) power operator needs specific typing for result
Date Tue, 02 Jun 2015 19:17:49 GMT
Christopher Smith created GROOVY-7449:

             Summary: power operator needs specific typing for result
                 Key: GROOVY-7449
             Project: Groovy
          Issue Type: Bug
          Components: Compiler
    Affects Versions: 2.4.3
            Reporter: Christopher Smith
            Priority: Minor

I wanted to use the power operator to set a static constant field:

public static final int DIGITS_IN_CODE = 4

static final int mod = 10 ** DIGITS_IN_CODE

This results in a compile-time exception when used with {{@CompileStatic}}:

Groovy:[Static type checking] - Cannot assign value of type java.lang.Number to variable of
type int

Replacing the symbolic constant with just {{10 ** 4}} produces the same bug. It appears that
power expressions are not getting resolved until runtime even if they're compile-time constant

This message was sent by Atlassian JIRA

View raw message