[ 
https://issues.apache.org/jira/browse/GROOVY-7627?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14954778#comment-14954778
 ] 

ASF GitHub Bot commented on GROOVY-7627:
----------------------------------------

Github user blackdrag commented on a diff in the pull request:

    https://github.com/apache/incubator-groovy/pull/139#discussion_r41852510
  
    --- Diff: src/test/groovy/transform/stc/GenericsSTCTest.groovy ---
    @@ -1613,6 +1613,8 @@ assert result == 'ok'
                 class ComponentFixture<T extends Component> {}
                 class JButtonFixture extends ComponentFixture<JButton> {}
                 class ContainerFixture<T extends Container> extends 
ComponentFixture<T> {}
    +
    +            
@groovy.transform.TypeChecked(groovy.transform.TypeCheckingMode.SKIP)
    --- End diff --
    
    you mean the compilation of that class would fail without this?


> Property calls are not correctly type checked if the setter parameter type or 
> getter return type are not the field type
> -----------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7627
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7627
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.4.5
>         Environment: JDK 1.8.0_60
>            Reporter: Shil Sinha
>            Assignee: Cédric Champeau
>
> If a class defines a property but also explicitly provides a getter or 
> setter, property style get/set calls are type checked using the underlying 
> field type rather than the getter return type/setter parameter type.
> Setter example:
> {code}
> class Foo {
>     Bar bar;
>     void setBar(int x) {
>         this.bar = new Bar(x: x)
>     }
> }
> class Bar {
>     int x
> }
> @groovy.transform.TypeChecked
> void test() {
>     Foo foo = new Foo()
>     foo.bar = new Bar()
> }
> test()
> {code}
> The code above will pass STC and throw a GroovyCastException at runtime. 
> Conversely, code like {{foo.bar = 1}} will not pass STC.  The case for 
> getters with return type different from the field type is similar.



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

Reply via email to