You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Dmitry Ovchinnikov (JIRA)" <ji...@apache.org> on 2015/05/04 17:54:05 UTC

[jira] [Updated] (GROOVY-7412) Map-to-interface cast: map method definition does not override the default method

     [ https://issues.apache.org/jira/browse/GROOVY-7412?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dmitry Ovchinnikov updated GROOVY-7412:
---------------------------------------
    Environment: 
JDK 1.8u45
Ubuntu 15.04 x86_64
Groovy 2.4.3

> Map-to-interface cast: map method definition does not override the default method
> ---------------------------------------------------------------------------------
>
>                 Key: GROOVY-7412
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7412
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 2.4.3
>         Environment: JDK 1.8u45
> Ubuntu 15.04 x86_64
> Groovy 2.4.3
>            Reporter: Dmitry Ovchinnikov
>
> The following code
> {code:groovy}
> import groovy.lang.GroovyShell;
> import org.codehaus.groovy.control.CompilerConfiguration;
> public class InterfaceDefaultMethods {
>     public static void main(String... args) throws Exception {
>         final CompilerConfiguration cc = new CompilerConfiguration();
>         cc.setTargetBytecode(CompilerConfiguration.JDK8);
>         final GroovyShell shell = new GroovyShell(cc);
>         final X x = (X) shell.evaluate("[x : {-> 3}, z: {-> 19}] as " + X.class.getCanonicalName());
>         System.out.format("x = %d, y = %d, z = %d%n", x.x(), x.y(), x.z());
>     }
>     public interface X {
>         default int x() {
>             return 1;
>         }
>         default int y() {
>             return 2;
>         }
>         int z();
>     }
> }
> {code}
> produces
> {noformat}
> x = 1, y = 2, z = 19
> {noformat}
> but x must be 3.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)