Created
October 25, 2014 09:36
-
-
Save jrudolph/cfa1cbce46c3d7cb4d92 to your computer and use it in GitHub Desktop.
Getting return types of methods without actually calling them
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.reflect.{ classTag, ClassTag } | |
trait X { | |
def f: Seq[Int] | |
} | |
trait Getter[T] { | |
def apply[U: ClassTag, C[_]](f: T ⇒ C[U]): ClassTag[U] = implicitly[ClassTag[U]] | |
} | |
object Getter extends Getter[Any] | |
def memberClassTagFrom[T]: Getter[T] = Getter.asInstanceOf[Getter[T]] | |
println(memberClassTagFrom[X](_.f)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment