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:33:00 UTC

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

Eric Milles created GROOVY-10002:
------------------------------------

             Summary: 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


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}



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