[ https://issues.apache.org/jira/browse/GROOVY-10006?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17315819#comment-17315819 ]
Eric Milles edited comment on GROOVY-10006 at 11/11/24 8:36 PM: ---------------------------------------------------------------- GROOVY-5692 is when the STC error was added. If either argument is a subtype of the other, like if one was Long and the other Number or one was String and the other Object, Number or Object will be used for U. There is also a test case like: {code:groovy} def <T> foo(T t, List<? extends T> list) { } foo(1,[""]) {code} was (Author: emilles): GROOVY-5692 is when the STC error was added. If either argument is a subtype of the other, like if one was Long and the other Number or one was String and the other Object, Number or Object will be used for U. There is also a test case like: {code:groovy} def <T> foo(T t, List<T> list) { } foo(1,[""]) {code} > @CompileStatic fails to unify types > ----------------------------------- > > Key: GROOVY-10006 > URL: https://issues.apache.org/jira/browse/GROOVY-10006 > Project: Groovy > Issue Type: Bug > Components: Static compilation, Static Type Checker > Affects Versions: 3.0.6 > Reporter: Konstantin Nisht > Assignee: Eric Milles > Priority: Major > Fix For: 4.0.0-alpha-3, 2.5.19, 3.0.13 > > Time Spent: 0.5h > Remaining Estimate: 0h > > {code:groovy} > @CompileStatic > class A { > static <U> void foo(U a, U b) {} > static void main(String[] args) { > foo(1, "") > } > } > {code} > The following code fails to compile with error > {{Groovyc: [Static type checking] - Cannot call <U> A#foo(U, U) with > arguments [int, java.lang.String]}} > {{U}} should be inferred to LUB(Integer, String), hence the call should be > successful. -- This message was sent by Atlassian Jira (v8.20.10#820010)