[ https://issues.apache.org/jira/browse/GROOVY-7701?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15062507#comment-15062507 ]
John Wagenleitner edited comment on GROOVY-7701 at 12/17/15 6:36 PM: --------------------------------------------------------------------- Not sure, I would suspect not but it wouldn't hurt to test. You can also compare against dropping the delegate and calling the setter {{setType(...)}} and that should also work as a workaround. was (Author: jwagenleitner): Not sure, I would suspect not but it would hurt to test. You can also compare against dropping the delegate and calling the setter {{setType(...)}} and that should also work as a workaround. > org.codehaus.groovy.runtime.typehandling.GroovyCastException in Groovy ".with > { ... }" - Block > ---------------------------------------------------------------------------------------------- > > Key: GROOVY-7701 > URL: https://issues.apache.org/jira/browse/GROOVY-7701 > Project: Groovy > Issue Type: Bug > Components: groovy-jdk > Affects Versions: 2.4.3, 2.4.4, 2.4.5 > Environment: all? > Tested with Ubuntu 14.04.3 LTS (64 Bit) | MacOS 10.11 and Groovy 2.4.5, 2.3.4 > Reporter: Maik Igloffstein > > h1. Problem > {code} > subClass.with { > type = ['String'] > } > {code} > Should change _SubClass.type_ and not _TopClass.type_. > The script works fine with _type2_ instead of _type_. Is _type_ a reserved > word? I can't find any documentation about this. > h2. Unit-Test / Groovy Console-Test > {code} > class SubClass{ > List type > } > class TopClass{ > int type = 10 > @Lazy > List something = { > List tmp = [] > for(int i = 0; i < 5; i++){ > def subClass = new SubClass() > subClass.with { > type = ['String'] // throws > org.codehaus.groovy.runtime.typehandling.GroovyCastException > } > tmp.add(subClass) > } > tmp > }() > } > def topClass = new TopClass() > println GroovySystem.version > println(topClass.type) > println(topClass.something) > println(topClass.type) > {code} > h2. Exception > {code} > org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast > object '[String]' with class 'java.util.ArrayList' to class 'int' > at TopClass$_getSomething_closure1$_closure2.doCall(ConsoleScript3:15) > at TopClass$_getSomething_closure1.doCall(ConsoleScript3:14) > at TopClass$_getSomething_closure1.doCall(ConsoleScript3) > at TopClass.getSomething(ConsoleScript3:11) > at ConsoleScript3.run(ConsoleScript3:26) > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)