You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Stefanos Chaliasos (Jira)" <ji...@apache.org> on 2021/06/28 17:22:00 UTC
[jira] [Created] (GROOVY-10153) STC: cannot combine use-variance
with bounded polymorphism
Stefanos Chaliasos created GROOVY-10153:
-------------------------------------------
Summary: STC: cannot combine use-variance with bounded polymorphism
Key: GROOVY-10153
URL: https://issues.apache.org/jira/browse/GROOVY-10153
Project: Groovy
Issue Type: Bug
Components: Static compilation, Static Type Checker
Affects Versions: 4.0.0-alpha-3
Reporter: Stefanos Chaliasos
I have the following Groovy program.
{code:groovy}
@groovy.transform.TypeChecked
class Test {
public void m() {
Foo<? super C> x = new Foo<B>();
}
}
class A {}
class B extends A {}
class C extends B {}
class Foo<T extends A> {
}
{code}
h2. Actual Behavior
The program does not compile, and I get the following error.
{code:java}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Test.groovy: 4: The type ? is not a valid substitute for the bounded parameter <T extends A>
@ line 4, column 9.
Foo<? super C> x = new Foo<B>();
^
1 error
{code}
h2. Expected Behavior
Compile successfully.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)