Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.reflect.runtime.universe.TypeTag
- class GoodAsInstanceOf {
- def takesTypeTag[A : TypeTag](a: A): String = {
- val tt = implicitly[TypeTag[A]]
- s"The tt of A is $tt"
- }
- def exerciseIt(): String = {
- takesTypeTag("Hello")
- }
- }
- // GoodAsInstanceOf.scala
- package <empty> {
- import scala.reflect.runtime.`package`.universe.TypeTag;
- class GoodAsInstanceOf extends scala.AnyRef {
- def <init>(): GoodAsInstanceOf = {
- GoodAsInstanceOf.super.<init>();
- ()
- };
- def takesTypeTag[A >: Nothing <: Any](a: A)(implicit evidence$1: reflect.runtime.universe.TypeTag[A]): String = {
- val tt: reflect.runtime.universe.TypeTag[A] = scala.this.Predef.implicitly[reflect.runtime.universe.TypeTag[A]](evidence$1);
- scala.StringContext.apply("The tt of A is ", "").s(tt)
- };
- def exerciseIt(): String = GoodAsInstanceOf.this.takesTypeTag[String]("Hello")({
- val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
- val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[GoodAsInstanceOf].getClassLoader());
- $u.TypeTag.apply[String]($m, {
- final class $typecreator1 extends TypeCreator {
- def <init>(): $typecreator1 = {
- $typecreator1.super.<init>();
- ()
- };
- def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = {
- val $u: U = $m$untyped.universe;
- val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
- $m.staticClass("java.lang.String").asType.toTypeConstructor
- }
- };
- new $typecreator1()
- })
- })
- }
- }
- // Ignore usage in synthetic classes
- case ClassDef(_, _, _, _) if synthetic =>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement