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 to scala function to return Class[type] of object of type T rather than Class[_] returned by getClass #4696
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4696?orig=1 |
@paulp said: |
Richard Emberson (rmemberson) said: |
@paulp said: |
@adriaanm said: |
@SethTisue said: |
@paulp said: HEY ADRIAAN, IF YOU CAN HEAR ME UP THERE EVEN THOUGH SETH IS STANDING BETWEEN US, WE CAN'T CALL IT GETCLASS UNLESS YOU MEAN REPLACING THE JAVA.LANG.OBJECT GETCLASS. I'M NOT SURE THAT'S EITHER POSSIBLE OR WISE. PUTTING IT IN PREDEF IS NOT RIGHT IN MY OPINION, IT SHOULD BE A METHOD ON "RICHCLASS". AND THEN OF COURSE IT CAN'T BE CALLED GETCLASS BECAUSE EVERYONE ALREADY HAS THAT METHOD. |
@adriaanm said: |
@adriaanm said: PS: DO YOU READ ME? |
@paulp said: |
@SethTisue said: In Java 6 "The actual result type is Class<? extends |X|> where |X| is the erasure of the static type of the expression on which getClass is called." See #490. |
@ijuma said: |
@odersky said: |
@paulp said: |
@ijuma said: |
Commit Message Bot (anonymous) said: def f1 = 5.getClass // Class[Int] class A def f1 = (new B: Any).getClass().newInstance() // Any But that's not all! def f0[T >: B] = (new B: T).getClass().newInstance() def f5 = f0[Any] // Any Closes #490, #896, #4696. Review by moors. (Note: I think this is |
please add the following to (maybe) PreDef:
Using the Java Object getClass method which returns a Class[_] is so Java.
Please, I want something that returns Class[type-of-object].
Thanks
The text was updated successfully, but these errors were encountered: