You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/03/27 04:37:00 UTC

[jira] [Updated] (GROOVY-10002) STC: inconsistent support for assignment of list literals

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

Eric Milles updated GROOVY-10002:
---------------------------------
    Description: 
Consider the following:
{code:groovy}
@groovy.transform.TypeChecked
void test() {
  List<String> a = [] // okay
  Set<String> b = [] // okay
  Deque<String> c = [] // GroovyCastException at runtime
  Deque<String> d = [1,2,3] // error for unknown constructor (good) and error for incompatible generics (bad)
  ArrayDeque<String> e = [123] // ArrayDeque(int numElements); error for incompatible generics (bad)
  Set<String> f = ['foo', 'bar', 'foo'] // error for unknown constructor (castToType would handle this at runtime if allowed) and error for incompatible generic types (wrong)
}
{code}

  was:
Consider the following:
{code:groovy}
@groovy.transform.TypeChecked
void test() {
  List<String> a = [] // okay
  Set<String> b = [] // okay
  Deque<String> c = [] // GroovyCastException at runtime
  Deque<String> d = [1,2,3] // error for unknown constructor (good) and error for incompatible generics (bad)
  ArrayDeque<String> e = [123] // ArrayDeque(int numElements); error for incompatible generics (bad)
  Set<String> f = ['foo', 'bar', 'foo'] // error for unknown constructor; castToType would handle this at runtime if allowed
}
{code}


> STC: inconsistent support for assignment of list literals
> ---------------------------------------------------------
>
>                 Key: GROOVY-10002
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10002
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> @groovy.transform.TypeChecked
> void test() {
>   List<String> a = [] // okay
>   Set<String> b = [] // okay
>   Deque<String> c = [] // GroovyCastException at runtime
>   Deque<String> d = [1,2,3] // error for unknown constructor (good) and error for incompatible generics (bad)
>   ArrayDeque<String> e = [123] // ArrayDeque(int numElements); error for incompatible generics (bad)
>   Set<String> f = ['foo', 'bar', 'foo'] // error for unknown constructor (castToType would handle this at runtime if allowed) and error for incompatible generic types (wrong)
> }
> {code}



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