You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2015/06/01 13:59:17 UTC

[jira] [Updated] (GROOVY-7446) setting list values via slicing not working with @TypeChecked

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

Paul King updated GROOVY-7446:
------------------------------
    Description: 
As a follow on from GROOVY-6212, the following code:
{code}
@groovy.transform.TypeChecked
def myMethod() {
  def orig = 'a'..'f'

  def items = orig.toList()
  items[1..2] = 'X'
  assert items == ['a', 'X', 'd', 'e', 'f']

  items = orig.toList()
  items[*1..2] = 'X'
  assert items == ['a', 'X', 'X', 'd', 'e', 'f']

  items = orig.toList()
  items[*1..2, 4] = 'X'
  assert items == ['a', 'X', 'X', 'd', 'X', 'f']
}
myMethod()
{code}
fails compilation with the following errors:
{noformat}
[Static type checking] - Cannot assign value of type java.lang.String to variable of type java.util.List <java.lang.String>
 at line: 18, column: 17

[Static type checking] - Cannot assign value of type java.lang.String to variable of type java.util.List <java.lang.String>
 at line: 22, column: 18

[Static type checking] - Cannot assign value of type java.lang.String to variable of type java.util.List <java.lang.String>
 at line: 26, column: 21
{noformat}


  was:
As a follow on from GROOVY-6212, the following code:
{code}
@groovy.transform.TypeChecked
def myMethod() {
  def orig = 'a'..'f'

  def items = orig.toList()
  items[1..2] = 'X'
  assert items == ['a', 'X', 'd', 'e', 'f']

  items = orig.toList()
  items[*1..2] = 'X'
  assert items == ['a', 'X', 'X', 'd', 'e', 'f']

  items = orig.toList()
  items[*1..2, 4] = 'X'
  assert items == ['a', 'X', 'X', 'd', 'X', 'f']
}
myMethod()
{code}
throws the following errors:
{noformat}
[Static type checking] - Cannot assign value of type java.lang.String to variable of type java.util.List <java.lang.String>
 at line: 18, column: 17

[Static type checking] - Cannot assign value of type java.lang.String to variable of type java.util.List <java.lang.String>
 at line: 22, column: 18

[Static type checking] - Cannot assign value of type java.lang.String to variable of type java.util.List <java.lang.String>
 at line: 26, column: 21
{noformat}



> setting list values via slicing not working with @TypeChecked
> -------------------------------------------------------------
>
>                 Key: GROOVY-7446
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7446
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.4.3
>            Reporter: Paul King
>            Assignee: Cédric Champeau
>
> As a follow on from GROOVY-6212, the following code:
> {code}
> @groovy.transform.TypeChecked
> def myMethod() {
>   def orig = 'a'..'f'
>   def items = orig.toList()
>   items[1..2] = 'X'
>   assert items == ['a', 'X', 'd', 'e', 'f']
>   items = orig.toList()
>   items[*1..2] = 'X'
>   assert items == ['a', 'X', 'X', 'd', 'e', 'f']
>   items = orig.toList()
>   items[*1..2, 4] = 'X'
>   assert items == ['a', 'X', 'X', 'd', 'X', 'f']
> }
> myMethod()
> {code}
> fails compilation with the following errors:
> {noformat}
> [Static type checking] - Cannot assign value of type java.lang.String to variable of type java.util.List <java.lang.String>
>  at line: 18, column: 17
> [Static type checking] - Cannot assign value of type java.lang.String to variable of type java.util.List <java.lang.String>
>  at line: 22, column: 18
> [Static type checking] - Cannot assign value of type java.lang.String to variable of type java.util.List <java.lang.String>
>  at line: 26, column: 21
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)