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

Implicit closure coercion conflicts with DGM methods in type checked mode

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.1
    • 2.3.0-beta-1
    • None
    • None

    Description

      The problem is highlighted with Java 8, where a Collection.sort(Comparator) method has been added. Given the following code:

      list.sort { a,b -> a<=>b }
      

      which takes a closure, then the type checker chooses the default method from Collection, Collection.sort(Comparator) because an implicit coercion of Closure to Comparator is possible.

      However, there's a DGM#sort(Collection,Closure) method which should have been preferred.

      The result is a build failure as seen in http://148.251.23.208:8111/viewLog.html?buildId=35&tab=buildResultsDiv&buildTypeId=Groovy_Jdk8Build

      Attachments

        Activity

          People

            melix Cédric Champeau
            melix Cédric Champeau
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: