Repository navigation
Conversation
…ctional interface gets its SAM constructor
`static Function<String,Integer> parser() { return Util::parse; }` printed `= Util ::parse`,
which Kotlin types as a KFunction1, no java.util.function.Function (return type mismatch); a local
`Function<String, Integer> f = Util::parse` lost its declared type the same way. As an argument
Kotlin converts the reference itself, which is why that case compiled.
Now: `Function<String, Int>(Util ::parse)` for returned and assigned values, when the interface
has no wildcard type arguments; arguments are unchanged.
Test: TestJavaToKotlinCalls.staticReferenceReturnedAsFunction (output compiles with kotlinc).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tom Tourwe <Tom.Tourwe@codelaser.io>
Contributor
|
Thanks. Devel had already fixed this independently (the method-reference SAM constructor in The whole batch (#146–#155) passes the Kotlin, C#, printer, front-end, inspection and bytecode suites on JDK 26 and JDK 27. It goes into 🤖 Generated with Claude Code |
bnaudts
pushed a commit
that referenced
this pull request
Oct 20, 2026
…tatic method reference returned as a Function The tests of #148 and #149. Their fixes were already on devel in another form (ba7a889 and the method-reference SAM constructor in assigned()); the tests pass without them and stay as regression tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
static Function<String,Integer> parser() { return Util::parse; }printed= Util ::parse,which Kotlin types as a KFunction1, no java.util.function.Function (return type mismatch); a local
Function<String, Integer> f = Util::parselost its declared type the same way. As an argumentKotlin converts the reference itself, which is why that case compiled.
Now:
Function<String, Int>(Util ::parse)for returned and assigned values, when the interfacehas no wildcard type arguments; arguments are unchanged.
Test: TestJavaToKotlinCalls.staticReferenceReturnedAsFunction (output compiles with kotlinc).
How it was found
A mutation-testing run (PIT) over the lines that maddi's latest 100 commits changed listed the changed code no
existing test checks. Tests written for those lines, from what each commit says the code should do, exposed this
bug while writing tests for aa93b0e; the bug is older than that commit.
Tests
On
devel07b926b: the new test fails without the fix and passes with it.With this fix and the nine others of this series applied together, every maddi test passes
(run on 7bc974b: 2,743 tests, 0 failures).
🤖 Generated with Claude Code