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/05/21 17:08:00 UTC

[jira] [Created] (GROOVY-10103) Lambda with command method call fails with cast exception

Eric Milles created GROOVY-10103:
------------------------------------

             Summary: Lambda with command method call fails with cast exception
                 Key: GROOVY-10103
                 URL: https://issues.apache.org/jira/browse/GROOVY-10103
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 4.0.0-alpha-3
            Reporter: Eric Milles


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

Supplier<String> s = () -> 'hello'
print s.get()

Consumer<String> c = x -> print x;
c.accept(' ')

Function<Integer, String> f = (Integer i) -> { 'world' }
print f(42)
{code}

This script prints "hello world" under Groovy 3 but fails at runtime under Groovy 4 with exception:
{code}
org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'interface java.util.function.Consumer' with class 'java.lang.Class' to class 'java.util.function.Consumer'
{code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)