You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "zzy (Jira)" <ji...@apache.org> on 2020/07/26 11:47:00 UTC

[jira] [Updated] (GROOVY-9660) generic type class extend tarit

     [ https://issues.apache.org/jira/browse/GROOVY-9660?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

zzy updated GROOVY-9660:
------------------------
    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:*

{color:#ff0000}org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:{color}
 {color:#ff0000}TestTrait.groovy: 11: The type TestData is not a valid substitute for the bounded parameter <D extends io.github.hdfg159.Data>{color}
 {color:#ff0000} @ line 11, column 29.{color}
 {color:#ff0000} def test = new AbstractData<TestData>(){color}

 

 What should i do to compile

 

 

  was:
*code example :*

package io.github.hdfg159

 

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:*

{color:#FF0000}org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:{color}
{color:#FF0000}TestTrait.groovy: 11: The type TestData is not a valid substitute for the bounded parameter <D extends io.github.hdfg159.Data>{color}
{color:#FF0000} @ line 11, column 29.{color}
{color:#FF0000} def test = new AbstractData<TestData>(){color}

 

 

 

 


> generic type class extend tarit
> -------------------------------
>
>                 Key: GROOVY-9660
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9660
>             Project: Groovy
>          Issue Type: Question
>          Components: Groovy Console
>    Affects Versions: 3.0.5
>         Environment: groovy 3.0.5 + jdk1.8
>            Reporter: zzy
>            Priority: Major
>              Labels: build
>
> *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:*
> {color:#ff0000}org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:{color}
>  {color:#ff0000}TestTrait.groovy: 11: The type TestData is not a valid substitute for the bounded parameter <D extends io.github.hdfg159.Data>{color}
>  {color:#ff0000} @ line 11, column 29.{color}
>  {color:#ff0000} def test = new AbstractData<TestData>(){color}
>  
>  What should i do to compile
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)