You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/06/20 13:40:00 UTC
[jira] [Assigned] (GROOVY-10662) Fail to substitute type variable when encountering conflicting type parameter with a bound
[ https://issues.apache.org/jira/browse/GROOVY-10662?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles reassigned GROOVY-10662:
------------------------------------
Assignee: Eric Milles
> Fail to substitute type variable when encountering conflicting type parameter with a bound
> ------------------------------------------------------------------------------------------
>
> Key: GROOVY-10662
> URL: https://issues.apache.org/jira/browse/GROOVY-10662
> Project: Groovy
> Issue Type: Bug
> Components: Static Type Checker
> Reporter: Thodoris Sotiropoulos
> Assignee: Eric Milles
> Priority: Major
>
> This might be related to GROOVY-10367 and GROOVY-10309.
> I have the following program:
> {code}
> class A<X, T> {
> A(T p1, X p2) {}
> void foo(X x) {}
> }
> class B<T extends Number> {
> void test() {
> T x = (T) null;
> Character y = (Character) 'd';
> new A<>(y, x).foo((T) null);
> }
> }
> {code}
> h3. Actual behaviour
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> test.groovy: 12: [Static type checking] - Cannot find matching method A#foo(T). Please check if the declared type is correct and if the method exists.
> @ line 12, column 5.
> new A<>(y, x).foo((T) null);
> ^
> 1 error
> {code}
> h3. Expected behaviour
> Compile successfully
> **Notes:** To trigger this bug, the following conditions should be met:
> 1. The second type parameter of class A must have the same name with the type parameter of class B.
> 2. We must use the diamond operator for constructing the receiver object at line 12.
> Tested against master (commit: fface1c9fe7f20a1d4c50b4cb00ead62bfaa31cb)
--
This message was sent by Atlassian Jira
(v8.20.7#820007)