-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive when adding a method to a class with the same name as a method in the companion object #532
Comments
I think the warning is strictly speaking correct. When there is no overlap, a static forwarder is generated from
When adding a method with that same name to
So the change really does make the static forwarder method disappear. (I haven't checked, but I'm guessing it could lead to ambiguity otherwise?) Now when you only expect this method to be called from Scala code, I'm pretty sure the Scala compiler will never use the static forwarder, and instead just invoke the function on the object directly. So if you don't expect this method to be ever called from e.g. Java or Kotlin code, you can probably filter out this problem. I don't think this is a false positive in mima: this is exactly the kind of subtle/unexpected incompatibilities where mima is valuable for catching them early. Perhaps it'd be reasonable to have a configuration option to specify you don't expect your library to be called from JVM languages other than Scala, and in that case automatically filter out this scenario - I'm not sure it's worth it though. In any case it would be nice to document this scenario somewhere, as it's probably a common cause for confusion. Perhaps we could even mention it in the failure message? |
Thanks for the explanation @raboof! Agreed that this is not a false positive; sounds very important for Java/Kotlin interop usecases. |
💯
An option like that would increase the silent friction that Java users of Scala libraries suffer, which I'm not sure I want to back. Also I'm not sure if/when Scala calls the static forwarders: is it never?
🤔 🤔 🤔 It would be good to have docs in the compiler (spec?) that help explain the story around static forwarder emission... scala/bug#11305, which talks about generic signatures, gives a sense of how it's a convoluted story. Perhaps MiMa could move to giving error messages ala Skunk (from https://twitter.com/tpolecat/status/1288937569863041026): |
Given this in a previous version:
Adding a method
reserve
to the class itself, like so:triggers
DirectMissingMethodProblem
:Changing the method's name to
reserve2
causes the issue to not be reported.The text was updated successfully, but these errors were encountered: