Skip to content

Kotlin recipe DSL: attach method type on multi-param selector rewrites#8273

Draft
timtebeek wants to merge 1 commit into
mainfrom
tim/fix-sumof-method-type
Draft

Kotlin recipe DSL: attach method type on multi-param selector rewrites#8273
timtebeek wants to merge 1 commit into
mainfrom
tim/fix-sumof-method-type

Conversation

@timtebeek

Copy link
Copy Markdown
Member

The rewrite { } to { } after-template rendered placeholder types from IrType.classFqName only, which drops generic type arguments — so a raw kotlin.Function1 placeholder was emitted for lambda/selector parameters. Callees whose overload resolution depends on that generic argument (e.g. Iterable<T>.sumOf, which dispatches on the selector's return type) then failed to resolve, leaving the replacement J.MethodInvocation with a null JavaType.Method that fails assertValidTypes under default TypeValidation. This spells out concrete type arguments on the KotlinTemplate path (with ? extends/? super for variance), falling back to the raw spelling for non-concrete arguments so no already-resolving case regresses. Adds a sumBy → sumOf RewriteTest that fails before and passes after with full type validation.

…aceholders

The rewrite { } to { } after-template rendered placeholder types from
IrType.classFqName only, dropping generic type arguments. Callees whose
overload resolution depends on a generic argument (e.g. Iterable<T>.sumOf,
which dispatches on the selector's return type) then failed to resolve, so
the replacement J.MethodInvocation carried a null JavaType.Method and failed
assertValidTypes under default TypeValidation.

Spell out concrete type arguments on the KotlinTemplate path, falling back
to the raw spelling for non-concrete arguments.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jul 16, 2026
@timtebeek
timtebeek marked this pull request as draft July 16, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant