Skip to content

GROOVY-12536: SC: a lambda or method reference taking a String throws ClassCastException for a GString element of a List<String> - #3056

Merged
daniellansun merged 1 commit into
apache:masterfrom
daniellansun:GROOVY-12536
Oct 30, 2026
Merged

daniellansun merged 1 commit into
apache:masterfrom
daniellansun:GROOVY-12536

Conversation

@daniellansun

Copy link
Copy Markdown
Contributor

@codecov-commenter

codecov-commenter commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.15044% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.7843%. Comparing base (396e862) to head (b5e8847).

Files with missing lines Patch % Lines
...sc/StaticTypesMethodReferenceExpressionWriter.java 91.3044% 0 Missing and 6 partials ⚠️
...groovy/classgen/asm/sc/StaticInvocationWriter.java 91.6667% 0 Missing and 3 partials ⚠️
...roovy/classgen/asm/sc/StaticTypesLambdaWriter.java 87.5000% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #3056        +/-   ##
==================================================
+ Coverage     73.7763%   73.7843%   +0.0080%     
- Complexity      42753      42789        +36     
==================================================
  Files            1678       1678                
  Lines          147462     147568       +106     
  Branches        27899      27929        +30     
==================================================
+ Hits           108792     108882        +90     
- Misses          28513      28516         +3     
- Partials        10157      10170        +13     
Files with missing lines Coverage Δ
...roovy/classgen/asm/sc/StaticTypesLambdaWriter.java 90.0735% <87.5000%> (-0.1520%) ⬇️
...groovy/classgen/asm/sc/StaticInvocationWriter.java 76.4826% <91.6667%> (+1.2067%) ⬆️
...sc/StaticTypesMethodReferenceExpressionWriter.java 89.3365% <91.3044%> (+0.2609%) ⬆️

... and 16 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@daniellansun

Copy link
Copy Markdown
Contributor Author

Friendly ping: CI is green and this is ready for review. If there are no objections, I plan to merge it this weekend. Thanks!

… ClassCastException for a GString element of a List<String>

When a native lambda or method reference is typed as String because of a
type variable, LambdaMetafactory check-cast the argument to String before
Groovy could coerce a GString. Accept the erased parameter type and convert
a GString to String inside the lambda or a synthetic method-reference adapter.
@testlens-app

testlens-app Bot commented Oct 30, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: b5e8847
▶️ Tests: 125426 executed
⚪️ Checks: 26/26 completed


Learn more about TestLens at testlens.app/docs.

@daniellansun
daniellansun merged commit c95fe62 into apache:master Oct 30, 2026
27 checks passed
@codeconsole

Copy link
Copy Markdown
Contributor

@daniellansun Since this and #3022 were both merged, MethodReferenceTest.testMethodReferencesInStaticAndDefaultMethodsOfInterface fails on master on every JDK: the GString adapter is created private static final, and the JVM rejects ACC_FINAL on an interface method, so an interface with a statically compiled String::trim fails to load with ClassFormatError. GROOVY-12591 / #3116 leaves ACC_FINAL out in interfaces, as the other method reference helpers do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants