Skip to content

private method names are unnecessarily slippery #2840

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

Closed
scabug opened this issue Dec 26, 2009 · 2 comments
Closed

private method names are unnecessarily slippery #2840

scabug opened this issue Dec 26, 2009 · 2 comments

Comments

@scabug
Copy link

scabug commented Dec 26, 2009

Consider these two classes:

class S {
  private def foo(x: Int) = x*x
}
class S2 {
  private def foo(x: Int) = x*x
  
  def bar = 1 to 5 map foo
}

And the generated code:

// S1
private int foo(int);
// S2
public final int S2$$$$foo(int);

I realize that in S2 a public method must be created so S2$$$$anonfun$$bar$$1 can access it, however I propose the original private method ought to be generated as well, simply forwarding to the public method.

This came up because I'm spending time porting various java tools to scala in parallel with working on a bytecode library. People use reflection in all manner of interesting ways, among them calling getDeclaredMethod (which considers private methods) expecting to find a method with the same name as the one in the source. Seems like a reasonable expectation.

I realize there will most likely be situations where scala bytecode can't be as predictable as java, however this doesn't like one of them.

@scabug
Copy link
Author

scabug commented Dec 26, 2009

Imported From: https://issues.scala-lang.org/browse/SI-2840?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Jan 5, 2010

@hubertp said:
We are not really sure on how much good what make considering the amount of work to be put atm. I am closing, but if you have any ideas, more factors in favor of it (or eager to do it) then please reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant