You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thodoris Sotiropoulos (Jira)" <ji...@apache.org> on 2021/10/08 12:24:00 UTC
[jira] [Created] (GROOVY-10291) STC fails to substitute type
variable when using the diamond operator and calling a closure
Thodoris Sotiropoulos created GROOVY-10291:
----------------------------------------------
Summary: STC fails to substitute type variable when using the diamond operator and calling a closure
Key: GROOVY-10291
URL: https://issues.apache.org/jira/browse/GROOVY-10291
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
I have the following program
{code:java}
class A<X> {
X x;
A(X x) {
this.x = x
}
}
class Test<T> {
void foo() {
def closure = { T p -> "" }
T y = null
bar(new A<>(y).x) // works
closure(new A<>(y).x) // fails
}
void bar(T x) {}
}
{code}
h3. Actual behavior
{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
test.groovy: 15: [Static type checking] - Cannot call closure that accepts [T] with [X]
@ line 15, column 12.
closure(new A<>(y).x) // fails
^
1 error
{code}
h3. Expected behaviour
Compile successfully
Tested against master
--
This message was sent by Atlassian Jira
(v8.3.4#803005)