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 2022/11/18 08:55:00 UTC

[jira] [Created] (GROOVY-10846) Unable to resolve field from a bounded type parameter

Thodoris Sotiropoulos created GROOVY-10846:
----------------------------------------------

             Summary: 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


I have the following code

{code}
import java.util.function.Function;
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)