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

final modifier for non-abstract methods in traits is ignored

    XMLWordPrintableJSON

Details

    Description

      When using the final modifier in a trait non-abstract method signature, then:

      • compiler successfully compiles trait and class that implements it
      • final method of trait may be overridden in class that implements trait
      • if class implements trait and doesn't override trait final method, then this method is available as non-final method in class
      • documentation says absolutely nothing about this

      In other words, final modifier is ignored in trait methods: code works the same with or without it. Even if this behavior is expected, there's nothing about it in the documentation.

      Here's simple example gradle groovy project to demonstrate the issue: https://github.com/dburyak/groovy-bug-trait-final

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              dburyak Dmytro Buryak
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: