You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Huss (JIRA)" <ji...@apache.org> on 2017/01/15 23:40:26 UTC

[jira] [Created] (GROOVY-8053) Groovyc: anonymous class in static method cannot access its fields without "this"

Daniel Huss created GROOVY-8053:
-----------------------------------

             Summary: Groovyc: anonymous class in static method cannot access its fields without "this"
                 Key: GROOVY-8053
                 URL: https://issues.apache.org/jira/browse/GROOVY-8053
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 2.4.8
         Environment: JAVA_VERSION="1.8.0_111"
OS_NAME="Windows"
OS_VERSION="5.2"
OS_ARCH="amd64"
            Reporter: Daniel Huss


{code}
import groovy.transform.CompileStatic

@CompileStatic // also happens without it
final class TestCase {

    static thisShouldCompile() {

        Object o = new Object() {

            int inaccessible

            @Override
            int hashCode() {
                inaccessible++ // succeeds when qualified with "this"
                return super.hashCode()
            }
        }
    }

    static void main( String... args ) {
        thisShouldCompile()
        System.out.println( "Success" )
    }
}
{code}

Could be related to GROOVY-7020



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)