groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Sun (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-9215) Incorrect compile time access error is raised when using @CompileStatic and/or @TypeChecked
Date Sat, 10 Aug 2019 04:59:00 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-9215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16904320#comment-16904320
] 

Daniel Sun commented on GROOVY-9215:
------------------------------------

Thanks. Your sample project can be simplified as the following script:

{code:java}
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked

@TypeChecked
@CompileStatic
class Data {
    void getThing(Closure c){
        c("hello")
    }
}

@TypeChecked
@CompileStatic
class Op {
    public Data d = new Data()

    void aFunc(Closure c){
        c()
    }

    void broken() {
        aFunc({
            d.getThing({ String res ->
                println(" ")
            })
        })
    }
}

println Op.class
{code}

> Incorrect compile time access error is raised when using @CompileStatic and/or @TypeChecked
> -------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9215
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9215
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation, Static Type Checker
>    Affects Versions: 3.0.0-beta-1, 3.0.0-beta-2, 3.0.0-beta-3
>            Reporter: Grant Haywood
>            Priority: Major
>
> after 3.0.0-beta-1 was released, my project will no longer compile (it would compile
against alpha-4)
> Most of the classes are annotated with
> {code:java}
> @TypeChecked
> @CompileStatic{code}
> the error produced takes the form
> {code:java}
> Compiling with JDK Java compiler API.
> startup failed:
> .../kvdn/src/main/groovy/net/iowntheinter/kvdn/storage/kv/impl/KvOp.groovy: 123: Access
to java.lang.Object#D is forbidden @ line 123, column 17.
>                    D.getMap(this.strAddr, { AsyncResult<AsyncMap>
res ->
> {code}
> I believe the relevant code sections are:
>  
> {code:java}
> @TypeChecked
> @CompileStatic
> class KvOp extends KvdnOperation implements KVOperation {
>     public KVData D
> ...................
>     @Override
>     @TypeChecked
>     void submit(..........) {
> .................
>         startOperation(this.valueType, TXTYPE.KV_SUBMIT, key, content, {
> /*(ln123)*/    D.getMap(this.strAddr, { AsyncResult<AsyncMap> res ->
>    .....................
>             })
>         })
>     }
> {code}
>  
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)

Mime
View raw message