You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Björn Kautler (Jira)" <ji...@apache.org> on 2026/08/26 22:30:00 UTC

[jira] [Created] (GROOVY-12305) STC vs static compile: type-coercion in ternary expression is not handled properly in static compilation

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

             Summary: STC vs static compile: type-coercion in ternary expression is not handled properly in static compilation
                 Key: GROOVY-12305
                 URL: https://issues.apache.org/jira/browse/GROOVY-12305
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 4.0.31, 5.0.3, 6.0.0-alpha-1
            Reporter: Björn Kautler


This compiles and runs fine, printing {{{}c{}}}:
{code:java}
@groovy.transform.TypeChecked
class Foo {
  def foo() {
    Map foo = [a:[b:'c']] as Map
    println(foo.a instanceof Map ? foo.a.b : foo.a)
  }
}
new Foo().foo(){code}
If you swap {{TypeChecked}} for {{{}CompileStatic{}}}, it fails to compile at class generation phase, complaining that "Access to java.lang.Object#b is forbidden".



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