Repository navigation
Stop reporting static forwarders - #987
Conversation
|
The static forwarders are Java interop, which MiMa generally does not check. So skipping them seems more consistent. We do have We could consider adding a "java API mode" to MiMa, that would have to cover a lot more than the static forwarders. So IMO, skipping them is the most consistent thing to do. |
A static forwarder on a companion class lets Java code call an object's method, and MiMa does not protect Java clients elsewhere. Changing an object's method was reported twice, once for the forwarder, and Scala 2 dropping the forwarder of a method made private[foo] was reported as a break. MiMa now checks only the object's method. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
4edd562 to
a01aec2
Compare
kitbellew
left a comment
There was a problem hiding this comment.
A few minutes too late while I was discussing it with claude. Still, here is the answer we prepared.
Agreed: stop reporting static forwarders and check only the object's method. MiMa should not report what cannot break a Scala caller.
- A Scala caller never links to a forwarder:
A.foo()compiles toA$.MODULE$.foo(). Only Java and Kotlin link toA.foo. - MiMa already skips a
private[foo]method, which is public in bytecode and callable from Java. The boundary is the Scala API, and the forwarder is not in it. - The forwarder has no entry in the pickle, so #986 had to copy the object method's visibility onto it. Skipping it removes that bookkeeping.
- Every change in forwarder emission has produced reports no Scala caller can hit:
- #388 (scalac stopped forwarding bridges in 2.12.8 and 2.13.0)
- scala/scala3#10842 (Scala 3 keeps the forwarder of a
private[foo]method) - #532 (a class gains a method named like an object method, and the forwarder is dropped).
Caveats to undo:
- #367 and #532 decided the opposite: a missing forwarder is a break for Java and Kotlin callers.
- #381 asked to filter static reports without losing them.
- Claude (paraphrasing Albert)
A static forwarder on a companion class lets Java code call an object's method, and MiMa does not protect Java clients elsewhere. Changing an object's method was reported twice, once for the forwarder, and Scala 2 dropping the forwarder of a method made private[foo] was reported as a break. MiMa now checks only the object's method.