[ https://issues.apache.org/jira/browse/GROOVY-10717?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles updated GROOVY-10717: --------------------------------- Fix Version/s: 3.0.14 > Map to type coercion not working on abstract classes > ---------------------------------------------------- > > Key: GROOVY-10717 > URL: https://issues.apache.org/jira/browse/GROOVY-10717 > Project: Groovy > Issue Type: Bug > Affects Versions: 3.0.11, 4.0.2 > Reporter: Josh DeWitt > Assignee: Eric Milles > Priority: Major > Fix For: 4.0.6, 3.0.14 > > > I sometimes use maps as mock objects for test cases. One test case started > failing with groovy 3.0.11 and 4.0.2 where a map was being used as a mock for > an abstract class. Here is a simplified version of what is now failing. Note > that it does not fail if A is *not* abstract: > {code:java} > abstract class A { > String b > } > def a = [getB: { 'string b' }] as A > assert 'string b' == a.b{code} > > I also noticed that I don't get an UnsupportedOperationException when calling > functions that were not implemented in the map as described in > [https://groovy-lang.org/semantics.html#_map_to_type_coercion]. > MissingPropertyException seems to be working, though I can't seem to find a > way to get MissingMethodException. > {code:java} > abstract class A { > String b > String c > } > def a = [getB: { 'string b' }, getD: { 'string d' }] as A > assert null != a.c // Should get UnsupportedOperationException (doesn't work) > assert null != a.d // Should get MissingPropertyException (works) > assert null != a.getD() // Should get MissingMethodException (doesn't work) > {code} > > Possibly related to GROOVY-8243? -- This message was sent by Atlassian Jira (v8.20.10#820010)