[
https://issues.apache.org/jira/browse/GROOVY-6214?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King closed GROOVY-6214.
-----------------------------
Resolution: Duplicate
Assignee: Paul King
This appears fixed in 2.4.13, probably a duplicate of GROOVY-8260.
> Problem With CompileStatic And instanceof
> -----------------------------------------
>
> Key: GROOVY-6214
> URL: https://issues.apache.org/jira/browse/GROOVY-6214
> Project: Groovy
> Issue Type: Improvement
> Components: Compiler
> Affects Versions: 2.1.1, 2.1.5
> Environment: OX X 10.8.3
> Reporter: Jeff Brown
> Assignee: Paul King
> Priority: Major
>
> I think this should compile but it does not.
> {noformat}
> $ cat Demo.groovy
> import groovy.transform.CompileStatic
> @CompileStatic
> class Demo {
> List convertToList(Object arg) {
> List convertedList
>
> if(arg instanceof List) {
> convertedList = arg
> }
> convertedList
> }
> }
> $
> $ groovy -version
> Groovy Version: 2.1.5 JVM: 1.6.0_45 Vendor: Apple Inc. OS: Mac OS X
> $
> $ groovyc Demo.groovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> Demo.groovy: 10: [Static type checking] - Cannot assign value of type
> java.lang.Object to variable of type java.util.List
> @ line 10, column 29.
> convertedList = arg
> ^
> 1 error
> {noformat}
> Is this a bug?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)