[
https://issues.apache.org/jira/browse/GROOVY-12154?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18095707#comment-18095707
]
ASF GitHub Bot commented on GROOVY-12154:
-----------------------------------------
codecov-commenter commented on PR #2697:
URL: https://github.com/apache/groovy/pull/2697#issuecomment-4951429166
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/2697?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 69.1047%. Comparing base
([`c9363db`](https://app.codecov.io/gh/apache/groovy/commit/c9363dba83711e0b680546e275294a5ac1836485?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`e27f3d3`](https://app.codecov.io/gh/apache/groovy/commit/e27f3d357d01fc902cd9526b93b92b4bb54eca89?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 3 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/2697?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #2697 +/- ##
==================================================
- Coverage 69.1083% 69.1047% -0.0036%
- Complexity 34235 34236 +1
==================================================
Files 1537 1537
Lines 129310 129311 +1
Branches 23478 23479 +1
==================================================
- Hits 89364 89360 -4
- Misses 31936 31941 +5
Partials 8010 8010
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/2697?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...sgen/asm/sc/AbstractFunctionalInterfaceWriter.java](https://app.codecov.io/gh/apache/groovy/pull/2697?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fclassgen%2Fasm%2Fsc%2FAbstractFunctionalInterfaceWriter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2NsYXNzZ2VuL2FzbS9zYy9BYnN0cmFjdEZ1bmN0aW9uYWxJbnRlcmZhY2VXcml0ZXIuamF2YQ==)
| `94.1606% <100.0000%> (+1.5135%)` | :arrow_up: |
... and [7 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/2697/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests,
report on failures, and find test suite problems.
- :package: [JS Bundle
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save
yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
> `@CompileStatic` lambda with a primitive-typed parameter targeting a generic
> functional interface fails at runtime with `LambdaConversionException`
> ---------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12154
> URL: https://issues.apache.org/jira/browse/GROOVY-12154
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 6.0.0-alpha-2
> Reporter: Paul King
> Priority: Major
>
> Under {{@CompileStatic}}, a lambda whose parameter is declared with a
> *primitive* type (e.g. {{int}}) and whose target is a *generic* functional
> interface (e.g. {{Function<Integer, Integer>}}) compiles without error but
> throws {{BootstrapMethodError}} / {{LambdaConversionException}} the first
> time it is invoked. The generated implementation method keeps the primitive
> parameter type, but the erased/instantiated SAM signature is {{Object}}, and
> {{LambdaMetafactory}} will not insert the boxing conversion.
> h2. Steps to Reproduce
> {code:groovy}
> import java.util.function.Function
> import groovy.transform.CompileStatic
> @CompileStatic
> class T {
> Function<Integer, Integer> f = (int a) -> a * 2 // primitive param,
> generic SAM
> Integer m() { f.apply(5) }
> }
> new T().m() // <-- throws
> {code}
> h2. Expected
> Returns {{10}} — the same as the untyped and boxed equivalents (see
> workarounds). Or, if this form is genuinely unsupported, it should be a
> *compile-time* error, not a runtime crash.
> h2. Actual
> Compiles clean, then at first invocation:
> {noformat}
> java.lang.BootstrapMethodError: bootstrap method initialization exception
> Caused by: java.lang.invoke.LambdaConversionException:
> Type mismatch for dynamic parameter 0: int is not a subtype of class
> java.lang.Object
> {noformat}
> h2. Workarounds
> Declare the parameter untyped or boxed — both return {{10}}:
> {code:groovy}
> Function<Integer, Integer> f = (a) -> a * 2 // untyped -> OK
> Function<Integer, Integer> f = (Integer a) -> a * 2 // boxed -> OK
> {code}
> h2. Notes / scope
> * Reproduces with a *single* primitive parameter (above) and with multiple
> ({{(int a, int b) -> a + b}} on {{BiFunction<Integer,Integer,Integer>}}).
> * *Independent of default parameter values* — {{(int a, int b) -> …}} fails
> with no default at all; {{(a, b = 10) -> …}} and {{(Integer a, Integer b =
> 10) -> …}} both work. (Surfaced while checking GEP-27's lambda-default
> question; defaults themselves are fine.)
> * *Independent of the {{groovy.target.lambda.hoist}} flag* — fails
> identically with it off and on.
> * The lambda must target a *generic* SAM (type parameter erases to
> {{Object}}). A non-generic primitive SAM (e.g. {{IntUnaryOperator}}) is
> unaffected.
> h2. Likely origin
> {{org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter#convertParameterType}}
> (the GROOVY-9790 primitive/boxing reconciliation). For {{inferredType =
> int}} against {{parameterType = Integer}}, the {{else if
> (isPrimitiveType(inferredType))}} branch's condition is false, so it falls
> through to {{type = inferredType…}} ({{int}}) instead of boxing to
> {{Integer}} — producing an impl method the metafactory cannot link to the
> {{Object}}-erased SAM.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)