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

Verifier fails to check property types with covariant override

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.6, 2.0-rc-2
    • 1.8.7, 2.0.1
    • Compiler
    • None

    Description

      The following code Does not throw an compiler exception

      interface Addon {
         Map getFactories()
      }
      
      class AddonImpl implements Addon {
          Map factories
      }
      
      class SubAddon extends AddonImpl {
          def factories = [a:1]
      }
      

      whereas the method call will output the correct compiler error

      interface Addon {
         Map getFactories()
      }
      
      class AddonImpl implements Addon {
          Map getFactories() { [:] }
      }
      
      class SubAddon extends AddonImpl {
          def getFactories() { [:] }
      }
      

      the error being

      The return type of java.lang.Object getFactories() in SubAddon is incompatible with java.util.Map getFactories() in AddonImpl
      

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            aalmiray Andres Almiray
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: