[ 
https://issues.apache.org/jira/browse/GROOVY-11585?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles updated GROOVY-11585:
---------------------------------
    Description: 
The {{instanceof}} operator supports parameterized types.  However, the types 
are erased at runtime, so the check can be improper.  For example:
{code:groovy}
def list = [1,2,3]
if (list instanceof List<String>) {
  // yes List but not of String
}
{code}

The java compiler says "Cannot perform instanceof check against parameterized 
type List<String>. Use the form List<?> instead since further generic type 
information will be erased at runtime."

  was:
The {{instanceof}} operator supports parameterized types.  However, the types 
are erased at runtime, so the check can be improper.  For example:
{code:groovy}
def list = [1,2,3]
if (list instanceof List<String>) {
  // yes List but not of String
}
{code}


> instanceof with parameterized type
> ----------------------------------
>
>                 Key: GROOVY-11585
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11585
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> The {{instanceof}} operator supports parameterized types.  However, the types 
> are erased at runtime, so the check can be improper.  For example:
> {code:groovy}
> def list = [1,2,3]
> if (list instanceof List<String>) {
>   // yes List but not of String
> }
> {code}
> The java compiler says "Cannot perform instanceof check against parameterized 
> type List<String>. Use the form List<?> instead since further generic type 
> information will be erased at runtime."



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to