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

@SelfType in hierarchy with an interface in the middle

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.7
    • 2.4.8
    • Compiler

    Description

      interface Self {
          def bar()
      }
      
      @SelfType(Self)
      trait T {
          def foo() {
              println "foo called"
              bar()
          }
      }
      
      interface Middle extends T {}
      
      class C implements Middle {}
      
      new C().foo()
      

      Above code compiles fine but fails at run time with:

      groovy.lang.MissingMethodException: No signature of method: selftype.baseinterface.C.bar() is applicable for argument types: () values: []
      

      The compilation should fail like if Middle was a trait.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            paulk Paul King
            daniilo Daniil Ovchinnikov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment