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

Interface default method and static import precedence

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.21, 4.0.19, 5.0.0-alpha-6
    • None
    • None

    Description

      Consider the following:

      import static Bar.*
      
      interface Foo {
          default m() { 'Foo' }
      }
      class Bar {
          static  m() { 'Bar' }
      }
      
      class Baz implements Foo {
          void test() {
              assert m() == 'Foo'
          }
      }
      
      new Baz().test()
      

      The implicit-this method call "m()" has two possible sources. Since Foo is a super-interface, it should be the one selected. However, StaticImportVisitor does not detect that option and replaces the method call with "Bar.m()".

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: