[jira] [Commented] (GROOVY-9000) Unexpected type for super within non-static inner class

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (GROOVY-9000) Unexpected type for super within non-static inner class

Eric Milles (Jira)

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

Eric Milles commented on GROOVY-9000:
-------------------------------------

For STC, the type is set in {{StaticTypeCheckingVisitor}}
{code:java}
    public void visitVariableExpression(VariableExpression vexp) {
        super.visitVariableExpression(vexp);

        if (storeTypeForThis(vexp)) return;
        if (storeTypeForSuper(vexp)) return;
{code}

> Unexpected type for super within non-static inner class
> -------------------------------------------------------
>
>                 Key: GROOVY-9000
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9000
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.16
>            Reporter: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> class Foo {
>   class Bar {
>     def baz() {
>       super
>     }
>   }
> }
> {code}
> If I create an instance of Bar and call baz(), I receive the instance of Bar as the return value.  That is "super" in this context maps to the inner class itself.  This causes "super.whatever" to work like "this.whatever" or implicit-this "whatever", which is unexpected.  For example, I was able to call a private method of Foo using "super.method()" when I would expect method missing instead.



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