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/14 14:53:00 UTC
[jira] [Created] (GROOVY-10306) STC rejects program when assigning
a closure that returns a class field
Thodoris Sotiropoulos created GROOVY-10306:
----------------------------------------------
Summary: STC rejects program when assigning a closure that returns a class field
Key: GROOVY-10306
URL: https://issues.apache.org/jira/browse/GROOVY-10306
Project: Groovy
Issue Type: Bug
Components: Static Type Checker
Reporter: Thodoris Sotiropoulos
I have the following program
{code:java}
import java.util.function.Supplier;
class Main {
byte x = 1;
void foo() {
Supplier<Number> y = () -> x;
}
}
{code}
h3. Actual behaviour
{code}
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Main.java: 8: [Static type checking] - Incompatible generic argument types. Cannot assign java.util.function.Supplier<java.lang.Byte> to: java.util.function.Supplier<java.lang.Number>
@ line 8, column 31.
Supplier<Number> y = () -> x;
^
1 error
{code}
h3. Expected behaviour
Compile successfully
Note that if `x` is a local variabled defined in function `foo`, groovyc compiles the program successfully.
Tested against master
--
This message was sent by Atlassian Jira
(v8.3.4#803005)