Skip to content
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

constructor params hide getters from parent class in Type.members #8096

Open
scabug opened this issue Dec 20, 2013 · 3 comments
Open

constructor params hide getters from parent class in Type.members #8096

scabug opened this issue Dec 20, 2013 · 3 comments

Comments

@scabug
Copy link

scabug commented Dec 20, 2013

if a parameter to a constructor has the same name as the field of a parent class, that fields getter doesn't show up in calls to Type.members:

import scala.reflect.runtime.{universe => ru}
class A(var x: Int)
class B(x:Int, var y: Int) extends A(x)
scala> ru.typeOf[B].members.filter{_.name.toString.contains("x")}
res23: Iterable[reflect.runtime.universe.Symbol] = SynchronizedOps(value x, method x_=)

(notice that "method x", the getter, is missing.)

This only seems to be happening because the constructor for B has a parameter named "x" also. Normally, members does return inherited getters.

(also written up here: http://stackoverflow.com/questions/20692702/in-scala-reflection-why-do-constructor-params-hide-getters)

@scabug
Copy link
Author

scabug commented Dec 20, 2013

Imported From: https://issues.scala-lang.org/browse/SI-8096?orig=1
Reporter: Imran Rashid (imranr)
Affected Versions: 2.10.3

@scabug
Copy link
Author

scabug commented Dec 20, 2013

@paulp said:
Maybe it is trying to be broken in the same way as real life. See #3194, #4762, etc

@scabug
Copy link
Author

scabug commented Dec 20, 2013

@paulp said:
And #6880, don't miss that one. It's not realistic to expect reflection to make much sense when the model upon which it is reflecting makes so little itself.

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

2 participants