Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.4.1
Description
package org.dimitrovchi.groovybugs; import groovy.lang.GroovyShell; import org.codehaus.groovy.control.CompilerConfiguration; import org.codehaus.groovy.runtime.DefaultGroovyMethods; import org.junit.Assert; import org.junit.Test; import java.util.Map; /** * @author Dmitry Ovchinnikov */ public class MapToProxyTest { private final GroovyShell shell; public MapToProxyTest() { final CompilerConfiguration cc = new CompilerConfiguration(); cc.setTargetBytecode(CompilerConfiguration.JDK8); shell = new GroovyShell(cc); } @Test public void testMapToProxy() { final Map map = (Map) shell.evaluate("[x: {10}, y: {20}]"); final SomeInterface si = DefaultGroovyMethods.asType(map, SomeInterface.class); Assert.assertEquals(20, si.y()); Assert.assertEquals(10, si.x()); // assertion error: si.x() == 1 } public interface SomeInterface { default int x() { return 1; } int y(); } }
JDK 1.8u31
Attachments
Issue Links
- is duplicated by
-
GROOVY-7412 Map-to-interface cast: map method definition does not override the default method
- Closed
- relates to
-
GROOVY-10717 Map to type coercion not working on abstract classes
- Closed
- links to