groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-7446) setting list values via slicing not working with @TypeChecked
Date Mon, 01 Jun 2015 11:59:17 GMT

     [ 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)

Mime
View raw message