This is an automated email from the ASF dual-hosted git repository. paulk pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/groovy.git
commit a7e660f12186a7f9480276dd47e564a08e525872 Author: Eric Milles <eric.mil...@thomsonreuters.com> AuthorDate: Mon Mar 2 12:11:31 2020 -0600 GROOVY-9412: check bound for generics, not its superclass and interfaces (adjust test) --- src/test/groovy/bugs/Groovy9412.groovy | 35 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/test/groovy/bugs/Groovy9412.groovy b/src/test/groovy/bugs/Groovy9412.groovy index 820b52f..120665c 100644 --- a/src/test/groovy/bugs/Groovy9412.groovy +++ b/src/test/groovy/bugs/Groovy9412.groovy @@ -18,29 +18,32 @@ */ package groovy.bugs -import groovy.test.GroovyTestCase; -class Groovy9412 extends GroovyTestCase { - void testProtectedFieldInClosureInEnum(){ - assertScript ''' - import groovy.transform.TypeChecked +import groovy.transform.CompileStatic +import org.junit.Test - @TypeChecked - class MyClass { +import static groovy.test.GroovyAssert.assertScript - interface Foo {} +@CompileStatic +final class Groovy9412 { - enum Bar implements Foo { - AA + @Test + void testCovarianceOfEnumThatImplementsInterface() { + assertScript ''' + interface Foo { } - void F() { - List<Foo> g = [] - g.add(Bar.AA) + enum Bar implements Foo { + Baz } - } - assert new MyClass() - ''' + @groovy.transform.TypeChecked + def test() { + List<Foo> list = [] + list.add(Bar.Baz) // add(E) should accept Foo or Bar instances + return list + } + assert test().size() == 1 + ''' } }