[
https://issues.apache.org/jira/browse/GROOVY-11685?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17955417#comment-17955417
]
Eric Milles commented on GROOVY-11685:
--------------------------------------
This fails under STC because postProcessClosure accepts "unknown type that
extends ResultBase". It should be declared as "Consumer<ResultBase>" or
"Consumer<? super ResultBase>". I linked the issue detailing the wildcard
capture changes.
{code:groovy}
Consumer<? extends ResultBase> postProcessClosure
ResultBase analyzed = closure.apply(str)
postProcessClosure(analyzed)
{code}
> Static type checking fails with groovy 5.x
> ------------------------------------------
>
> Key: GROOVY-11685
> URL: https://issues.apache.org/jira/browse/GROOVY-11685
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 5.0.0-beta-1
> Reporter: Andriy Rysin
> Assignee: Eric Milles
> Priority: Major
>
> This project can compile and run under groovy-4 but fails static type
> checking with groovy-5. I could not find what would be wrong with the code.
> [https://github.com/brown-uk/nlp_uk]
> {noformat}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> file:/home/user/nlp_uk/src/main/groovy/ua/net/nlp/tools/TextUtils.groovy:
> 182: [Static type checking] - Cannot call
> java.util.function.Consumer#call(capture-o
> f ? extends ua.net.nlp.tools.TextUtils.ResultBase) with arguments
> [ua.net.nlp.tools.TextUtils$ResultBase]
> @ line 182, column 6.
> postProcessClosure(analyzed)
> ^
> file:/home/user/nlp_uk/src/main/groovy/ua/net/nlp/tools/TextUtils.groovy:
> 200: [Static type checking] - Cannot call
> java.util.function.Consumer#call(capture-o
> f ? extends ua.net.nlp.tools.TextUtils.ResultBase) with arguments
> [ua.net.nlp.tools.TextUtils$ResultBase]
> @ line 200, column 4.
> postProcessClosure(analyzed)
> ^
> file:/home/user/nlp_uk/src/main/groovy/ua/net/nlp/tools/tag/TagUnknown.groovy:
> 97: [Static type checking] - Incompatible generic argument types. Cannot
> assign
> java.util.List<java.lang.Object> to:
> java.util.List<ua.net.nlp.tools.tag.TagTextCore.TaggedToken>
> @ line 97, column 25.
> retTokens = opToTagMap.collect { e ->
> ^
> file:/home/user/nlp_uk/src/main/groovy/ua/net/nlp/tools/tag/TagUnknown.groovy:
> 136: [Static type checking] - Incompatible generic argument types. Cannot
> assig
> n java.util.List<? extends java.lang.Object> to:
> java.util.List<ua.net.nlp.tools.tag.TagTextCore.TaggedToken>
> @ line 136, column 16.
> return retTokens
> ^
> {noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)