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

Unexpected error when trait used as a generic type bound

    XMLWordPrintableJSON

    Details

    • Type: Question
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.0.5
    • Fix Version/s: 2.5.14, 3.0.6
    • Component/s: Groovy Console
    • Labels:
    • Environment:
      groovy 3.0.5 + jdk1.8

      Description

      code example :

      trait Data {}
      
      class TestData implements Data {}
      
      class AbstractData<D extends Data>{ D data }
      
      def test = new AbstractData<TestData>()
      

       

      when i compile groovy,it compile failed:

      1 compilation error:
      
      The type TestData is not a valid substitute for the bounded parameter <D extends Data>
       at line: 7, column: 29
      

       

      Is this the wrong way to write it?

       

       

        Attachments

          Activity

            People

            • Assignee:
              emilles Eric Milles
              Reporter:
              hdfg159 hdfg159
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: