Backport "Fix generic signatures for mixin forwarders conflicting type parameter names" to 3.8.0#24622
Merged
WojciechMazur merged 1 commit intorelease-3.8.0from Dec 2, 2025
Merged
Conversation
…r names Fixes #24134 f99dba2 started emitting Java generic signature for mixin forwarders. However, when generating Java generic signatures for mixin forwarders, method-level type parameters could shadow class-level type parameters with the same name. For example, when `JavaPartialFunction[A, B]` implements `PartialFunction1[A, B]`, ```scala trait Function1[-T1, +R]: def compose[A](g: A => T1): A => R = ??? trait PartialFunction[-A, +B] extends Function1[A, B]: def compose[R](k: PartialFunction[R, A]): PartialFunction[R, B] = ??? abstract class JavaPartialFunction[A, B] extends PartialFunction[A, B] ``` the generated mixin forwarder for `compose` in Function1 was like: ```java public abstract class JavaPartialFunction<A, B> implements scala.PartialFunction<A, B> { public <A> scala.Function1<A, B> compose(scala.Function1<A, A>); ``` which is obviously incorrect, the type parameter `A` of `compose[A]` is shadowed by the `A` in `JavaPartialFunction<A, B>`. The `compose`'s type parameter should use an unique name like: ```java public abstract class JavaPartialFunction<A, B> implements scala.PartialFunction<A, B> { public <T> scala.Function1<T, B> compose(scala.Function1<T, A>); ``` This commit fix the problem by - Tracks class-level type parameter names when generating method signatures - Renames conflicting method-level type parameters (A → A1, A2, etc.) [Cherry-picked 4e284c5]
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.
Backports #24567 to the 3.8.0-RC3.
PR submitted by the release tooling.