You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/11/18 17:46:00 UTC

[jira] [Created] (GROOVY-10375) SC: cast exception for private property access from lambda

Eric Milles created GROOVY-10375:
------------------------------------

             Summary: SC: cast exception for private property access from lambda
                 Key: GROOVY-10375
                 URL: https://issues.apache.org/jira/browse/GROOVY-10375
             Project: Groovy
          Issue Type: Bug
            Reporter: Eric Milles
            Assignee: Eric Milles


Consider the following:
{code:groovy}
import java.util.function.Supplier

@groovy.transform.CompileStatic
class C {
  private String getX() { 'x' }
  void test() {
    Supplier<String> s = () -> x // GroovyCastException: Cannot cast object 'class C' with class 'java.lang.Class' to class 'C'
    print s.get()
  }
}

new C().test()
{code}

If variable expression "x" is replaced by "getX()" this runs successfully.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)