[ 
https://issues.apache.org/jira/browse/GROOVY-7996?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17174337#comment-17174337
 ] 

Eric Milles commented on GROOVY-7996:
-------------------------------------

[~paulk] Could you open a new ticket that references this one and describes the 
idea a bit more?  I'm familiar with {{StaticTypeCheckingVisitor}}, but not 
{{MopAwareChecker}}.  Is that something that is registered by default or would 
the user be expected to add the checking extension?  If available by default, 
are there other checks made by STCV that could be spun off to separate checker 
class?

> Using with method with a closure that references a protected property 
> produces ClassCastException
> -------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7996
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7996
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.7
>            Reporter: Graeme Rocher
>            Priority: Major
>             Fix For: 2.5.9, 3.0.0-rc-2
>
>          Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> The following example:
> {code}
> class Foo {
>     Object propertyMissing(String name) {
>          return "stuff"
>     }
>     
>     void build(Closure callable) {
>          this.with(callable)
>     }
> }
> @groovy.transform.CompileStatic
> class Bar {
>     protected List bar = []
>     
>     boolean doStuff() {
>         Foo foo = new Foo()
>         foo.build {
>            return bar.isEmpty() 
>         }
>     }
> }
> new Bar().doStuff()
> {code}
> Produces 
> {code}
> java.lang.ClassCastException: java.lang.String cannot be cast to 
> java.util.List
>       at Bar$_doStuff_closure1.doCall(ConsoleScript3:19)
>       at Bar$_doStuff_closure1.call(ConsoleScript3)
>       at 
> org.codehaus.groovy.runtime.DefaultGroovyMethods.with(DefaultGroovyMethods.java:242)
>       at Bar.doStuff(ConsoleScript3:18)
>       at Ba
> {code}
> The equivalent code without CompileStatic prints:
> {code}
> Result: false
> {code}
> The behaviour of both should be he same IMO



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

Reply via email to