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

Error in @TypeChecked when method in both Interface and Superclass

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.2
    • 2.3.1
    • Static Type Checker
    • None

    Description

      This groovy code has a compilation error:

      import groovy.transform.TypeChecked
      
      interface Ifc
      {
        Object getProperty(String s)
      }
      
      class DuplicateMethodInIfc implements Ifc  // implemented in groovy.lang.GroovyObject
      {
      }
      
      @TypeChecked
      class Tester
      {
        DuplicateMethodInIfc dup = new DuplicateMethodInIfc()
        Object obj = dup.getProperty("foo")   // <== Error here
      }
      

      The error is: DuplicateMethodInIfc.groovy: 16: [Static type checking] - Reference to method is ambiguous. Cannot choose between [java.lang.Object
      Ifc#getProperty(java.lang.String), java.lang.Object groovy.lang.GroovyObject#getProperty(java.lang.String)]

      Attachments

        Activity

          People

            Unassigned Unassigned
            ngalarneau Neil Galarneau
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: