-
Notifications
You must be signed in to change notification settings - Fork 72
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
Add test for public method becomes private[lib] #375
Add test for public method becomes private[lib] #375
Conversation
It passed, so this isn't an accurate minimisation. |
There didn't appear to be a test for making a method package-private, so I wanted to verify the base case. Although, I tried to add the complexity of implicits and overloading that were in the issue from ScalaCheck. I wonder what I'm missing to reproduce this? I'll try some more... |
Here's the test failure, but it's not the same one... |
Yeah that the loss of a static forwarder, which is a potential bincompat concern. |
A simple test suggests that marking a static method as package-private should be binary compatible: package bar
class A[T](t: T)
object A {
def foo[T](x: T): A[T] = new A(x)
def foo[T](x: T, y: T): A[T] = new A(y)
} package bar
class A[T](t: T)
object A {
def foo[T]( x: T): A[T] = new A(x)
private[bar] def foo[T](x: T, y: T): A[T] = new A(y)
}
Here's package baz
object App {
def main(args: Array[String]): Unit = {
bar.A.foo[Int](1,2)
println("Success")
}
} Is this a false positive? |
No. Scala doesn't use the static method, it uses the non-static method on the singleton object value. The binary incompatibility is only observable at runtime by calling from Java. |
I've converted the example
package baz;
class App {
public static void main(String[] args) {
bar.A$.MODULE$.foo(1,2);
System.out.println("Success");
}
} |
Nope. |
Ok, now I follow. Yes, indeed. It fails with that single line change: package baz;
class App {
public static void main(String[] args) {
bar.A.foo(1,2); // !!!
System.out.println("Success");
}
} Resulting in:
Thanks for explaining this! Sorry for all the questions. |
This came up as an issue when updating to MiMa 0.5.0 in ScalaCheck, see typelevel/scalacheck#509