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

Scala Reflection typed Mirror.get #9739

Open
scabug opened this issue Apr 6, 2016 · 2 comments
Open

Scala Reflection typed Mirror.get #9739

scabug opened this issue Apr 6, 2016 · 2 comments

Comments

@scabug
Copy link

scabug commented Apr 6, 2016

Hey,

In Mirrors we have:

def get: Any

Would it be possible to have instead:

def get[T]: T

?

So that we don't have all the time to do a .get.asInstanceOf[T] ?

Maybe even better with a default to Any?

sealed class DefaultsToAny[A]

object DefaultsToAny {
  implicit def overrideDefault[A] = new DefaultsToAny[A]

  implicit def default = new DefaultsToAny[Any]
}

and

def get[T: DefaultToAny]: T
@scabug
Copy link
Author

scabug commented Apr 6, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9739?orig=1
Reporter: Joan (joan)

@scabug
Copy link
Author

scabug commented Sep 29, 2016

@SethTisue said:
I'm not sure this is desirable. The explicit "asInstanceOf" signals an unsafe cast is happening.

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