Björn Kautler created GROOVY-12292:
--------------------------------------

             Summary: Various combinations of type-checking and 
static-compilation do not correctly combine
                 Key: GROOVY-12292
                 URL: https://issues.apache.org/jira/browse/GROOVY-12292
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 4.0.31, 5.0.3, 3.0.25, 2.5.23
            Reporter: Björn Kautler


Given this code: 
https://groovyconsole.dev/?g=groovy_5_0&codez=eNrtkl8LgjAUxd_3KS4-6YvSv_fAXiKCQL_AmqtG6WQbgYTfPTXNWqUWRAXt8XLO2bk_LgtjLhSsBef7xFYCR3LFRWi7PIzZjk6SCIeMINYs8xRWDSo_iam7oWRLg0ojC0eDlEXrOQ-o7c2mC4TGWh-yw1KCT6XqwQFB9sbXVfJRQFeATasUABiGrbinRBYtTasYpuiO2cz_tM4Ry24Rl0tWVvLQCo4D5PQpUCG4eJSllQnayqQ1rBJFzaqvsapo_mFp29TIBm9A9sOwLqvUkIYvQ2ou-yy1J9K05T-P8-byRl9wea8haz3eDmyOjbPXaQ

{code:groovy}
import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
import groovy.transform.TypeChecked
import static groovy.transform.TypeCheckingMode.SKIP

@CompileDynamic
class Test1 {
    @CompileStatic
    def a() {
      "".toStrings()
    }

    @CompileStatic(SKIP)
    def b() {
      "".toStrings()
    }

    @TypeChecked
    def c() {
      "".toStrings() // compile error
    }

    @TypeChecked(SKIP)
    def d() {
      "".toStrings()
    }
}

@CompileStatic
class Test2 {
    @CompileDynamic
    def a() {
      "".toStrings()
    }

    @CompileStatic(SKIP)
    def b() {
      "".toStrings()
    }

    @TypeChecked
    def c() {
      "".toStrings() // compile error
    }

    @TypeChecked(SKIP)
    def d() {
      "".toStrings()
    }
}

@CompileStatic(SKIP)
class Test3 {
    @CompileDynamic
    def a() {
      "".toStrings()
    }

    @CompileStatic
    def b() {
      "".toStrings()
    }

    @TypeChecked
    def c() {
      "".toStrings() // compile error
    }

    @TypeChecked(SKIP)
    def d() {
      "".toStrings()
    }
}

@TypeChecked
class Test4 {
    @CompileDynamic
    def a() {
      "".toStrings() // compile error
    }

    @CompileStatic
    def b() {
      "".toStrings() // compile error
    }

    @CompileStatic(SKIP)
    def c() {
      "".toStrings() // compile error
    }

    @TypeChecked(SKIP)
    def d() {
      "".toStrings()
    }
}

@TypeChecked(SKIP)
class Test5 {
    @CompileDynamic
    def a() {
      "".toStrings()
    }

    @CompileStatic
    def b() {
      "".toStrings()
    }

    @CompileStatic(SKIP)
    def c() {
      "".toStrings()
    }

    @TypeChecked
    def d() {
      "".toStrings()
    }
}
{code}

I'd say the annotations do not combine correctly.
For example {{@CompileDynamic}} or {{@CompileStatic(SKIP)}} or 
{{@TypeChecked(SKIP)}} on class and {{@CompileStatic}} on method does not do 
type-check?
And also {{@TypeChecked(SKIP)}} on class and {{@TypeChecked}} on method does 
not do type-check?

At least those 4 combinations appear to be fishy to me.



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

Reply via email to