You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/02/10 21:41:01 UTC
[jira] [Closed] (GROOVY-10846) Unable to resolve field from a bounded type parameter
[ https://issues.apache.org/jira/browse/GROOVY-10846?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-10846.
------------------------------
> Unable to resolve field from a bounded type parameter
> -----------------------------------------------------
>
> Key: GROOVY-10846
> URL: https://issues.apache.org/jira/browse/GROOVY-10846
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
> Fix For: 3.0.14, 2.5.20, 4.0.7
>
>
> I have the following code
> {code}
> import java.util.function.Supplier;
> class A {
> public String x;
> }
> public class B<T extends A, X extends Supplier<T>> {
> void test(T p) {
> p.x = "str";
> }
> }
> {code}
> h3. Actual behavior
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 12: [Static type checking] - No such property: x for class: T
> @ line 12, column 5.
> p.x = "str";
> ^
> 1 error
> {code}
> h3. Expected behavior
> Compile successfully
> *Notes*: This error occurs only when there is a second bounded type parameter in class B, and the first type parameter (i.e., T) is used there.
> Tested against master (commit: 2095b9eb3b73c5bcf27625395c24fa5210890443)
--
This message was sent by Atlassian Jira
(v8.20.10#820010)