Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7813

Calling a non-static outer class method from a static class passes STC

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.6
    • Fix Version/s: 2.4.7
    • Component/s: Static Type Checker
    • Labels:
      None

      Description

      Example:

      @groovy.transform.TypeChecked
      class Foo {
          def bar() { 2 }
      
          static class Baz {
              def doBar() {
                  bar()
              }
          }
      }
      new Foo.Baz().doBar()
      

      The doBar() call in the method above results in a MissingMethodException. If the code is statically compiled rather than just type checked, a VerifyError occurs instead.

      The usage of ClassNode#isStaticClass() within StaticTypeCheckingVisitor#findMethod(ClassNode, String, ClassNode...) seems to be responsible, as the former does not return true when the receiver is a static class.

        Activity

        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user shils opened a pull request:

        https://github.com/apache/groovy/pull/309

        GROOVY-7813: Calling a non-static outer class method from a static cl…

        …ass should fail STC

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/shils/groovy GROOVY-7813

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/groovy/pull/309.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #309


        commit ef18f20a62a99ade18a4fac9028fca7edf61419a
        Author: Shil Sinha <shils@apache.org>
        Date: 2016-04-09T19:54:08Z

        GROOVY-7813: Calling a non-static outer class method from a static class should fail STC


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user shils opened a pull request: https://github.com/apache/groovy/pull/309 GROOVY-7813 : Calling a non-static outer class method from a static cl… …ass should fail STC You can merge this pull request into a Git repository by running: $ git pull https://github.com/shils/groovy GROOVY-7813 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/309.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #309 commit ef18f20a62a99ade18a4fac9028fca7edf61419a Author: Shil Sinha <shils@apache.org> Date: 2016-04-09T19:54:08Z GROOVY-7813 : Calling a non-static outer class method from a static class should fail STC
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user shils closed the pull request at:

        https://github.com/apache/groovy/pull/309

        Show
        githubbot ASF GitHub Bot added a comment - Github user shils closed the pull request at: https://github.com/apache/groovy/pull/309
        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user shils opened a pull request:

        https://github.com/apache/groovy/pull/310

        GROOVY-7813: Calling a non-static outer class method from a static cl…

        …ass should fail STC

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/shils/groovy GROOVY-7813

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/groovy/pull/310.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #310


        commit 95937844973ffe19b3d6a0954e41a79cee089c99
        Author: Shil Sinha <shils@apache.org>
        Date: 2016-04-09T19:54:08Z

        GROOVY-7813: Calling a non-static outer class method from a static class should fail STC


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user shils opened a pull request: https://github.com/apache/groovy/pull/310 GROOVY-7813 : Calling a non-static outer class method from a static cl… …ass should fail STC You can merge this pull request into a Git repository by running: $ git pull https://github.com/shils/groovy GROOVY-7813 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/310.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #310 commit 95937844973ffe19b3d6a0954e41a79cee089c99 Author: Shil Sinha <shils@apache.org> Date: 2016-04-09T19:54:08Z GROOVY-7813 : Calling a non-static outer class method from a static class should fail STC
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/groovy/pull/310

        Show
        githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/310

          People

          • Assignee:
            shils Shil Sinha
            Reporter:
            shils Shil Sinha
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development