scala3
scala3 copied to clipboard
Only rename method type params shadowing enclosing class type params
Previously, method type parameters were always renamed if they had the same name as any class type parameter, regardless of whether the class type parameter was actually used in the method signature.
As a result, we rename methods's type params for unnecessary names like: https://github.com/scala/scala3/issues/24671 (Note that renaming actually doesn't cause binary incompatibility, and this change is just for make generic signature a bit clear and silence false-positive MIMA reporting).
For example, in an example below, the Scala compiler rename the generic signature of bar to something like bar[T1](x: T1): T1 because T is used by Foo[T]. However, this is unnessary rename because none of T in method signature refer the T of Foo[T].
class Foo[T]:
def bar[T](x: T): T = ???
This commit makes the renaming conditional: Method type parameters are only renamed when
- (1) A class type parameter is referenced in the method signature, and
- (2) That class type parameter is shadowed by a method type parameter