[
https://issues.apache.org/jira/browse/GROOVY-12599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18140653#comment-18140653
]
ASF GitHub Bot commented on GROOVY-12599:
-----------------------------------------
testlens-app[bot] commented on PR #3126:
URL: https://github.com/apache/groovy/pull/3126#issuecomment-6720047161
## 🚨 Jobs failed without executing tests 🚨
### Failed Jobs without Test Failures
❌ [Check licenses / test
\(ubuntu-latest\)](https://github.com/apache/groovy/actions/runs/42469073133/job/128695341060?pr=3126)
❌ [Generate SNAPSHOT artifacts /
dist](https://github.com/apache/groovy/actions/runs/42469073743/job/128695343779?pr=3126)
❌ [Lint gate /
lint](https://github.com/apache/groovy/actions/runs/42469073300/job/128695341872?pr=3126)
❌ [jmh / test \(core-ag,
\\\\.perf\\\\.[A-G]\)](https://github.com/apache/groovy/actions/runs/42469073190/job/128695341540?pr=3126)
❌ [jmh / test \(core-hz,
\\\\.perf\\\\.[H-Z]\)](https://github.com/apache/groovy/actions/runs/42469073190/job/128695341225?pr=3126)
❌ [jmh / test \(grails-ez,
\\\\.perf\\\\.grails\\\\.[E-Z]\)](https://github.com/apache/groovy/actions/runs/42469073190/job/128695341581?pr=3126)
❌ [jmh-classic / test \(core-hz,
\\\\.perf\\\\.[H-Z]\)](https://github.com/apache/groovy/actions/runs/42469073273/job/128695342025?pr=3126)
❌ [jmh-classic / test \(grails-ad,
\\\\.perf\\\\.grails\\\\.[A-D]\)](https://github.com/apache/groovy/actions/runs/42469073273/job/128695342250?pr=3126)
🏷️ Commit: c5957ed6e79c60ea1a81fcf6fe6769cc3a56112c
▶️ Tests: 0 executed
🟡 Checks: 10/24 completed
### Rerun Controls
Click the checkbox to trigger a rerun:
🔲 **Rerun jobs**
---
_Learn more about TestLens at
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
> STC accepts a Closure<R> value passed to or returned as a functional
> interface whose method does not return R
> -------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12599
> URL: https://issues.apache.org/jira/browse/GROOVY-12599
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 4.0.33, 5.0.8, 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> {code:groovy}
> import java.util.function.Supplier
> @groovy.transform.CompileStatic // or @TypeChecked
> class C {
> static String take(Supplier<String> s) { s.get().toLowerCase() }
> static Supplier<String> make() { Closure<Integer> c = { 1 }; c }
> static void main(args) {
> Closure<Integer> c = { 1 }
> take(c)
> make().get().toLowerCase()
> }
> }
> {code}
> Actual: the code compiles. Under static compilation both calls throw
> {noformat}
> java.lang.ClassCastException: class java.lang.Integer cannot be cast to class
> java.lang.String
> {noformat}
> (MissingMethodException under @TypeChecked). The same happens for an instance
> of a non-generic subclass such as {{class D extends Closure<Integer>}} passed
> as the argument.
> Expected: compile errors, as for a closure literal ("Cannot return value of
> type int for closure expecting java.lang.String"):
> {noformat}
> Cannot call C#take(java.util.function.Supplier<java.lang.String>) with
> arguments [groovy.lang.Closure<java.lang.Integer>]
> Cannot return value of type groovy.lang.Closure<java.lang.Integer> for method
> returning java.util.function.Supplier<java.lang.String>
> {noformat}
> For a method argument,
> StaticTypeCheckingSupport.typeCheckMethodArgumentWithGenerics accepts any
> Closure for a SAM-type parameter and assumes the return type was checked
> earlier. That is only true for a closure literal. For a return statement,
> generics are compared only when the value's type implements the return type,
> which Closure does not for most SAM types.
> Seen in 4.0.33, 5.0.8 and 6.0.0.
> PR: https://github.com/apache/groovy/pull/3126
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)