Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. import scala.reflect.runtime.universe.TypeTag
  2.  
  3. class GoodAsInstanceOf {
  4. def takesTypeTag[A : TypeTag](a: A): String = {
  5. val tt = implicitly[TypeTag[A]]
  6. s"The tt of A is $tt"
  7. }
  8.  
  9. def exerciseIt(): String = {
  10. takesTypeTag("Hello")
  11. }
  12. }
  13.  
  14. // GoodAsInstanceOf.scala
  15. package <empty> {
  16. import scala.reflect.runtime.`package`.universe.TypeTag;
  17. class GoodAsInstanceOf extends scala.AnyRef {
  18. def <init>(): GoodAsInstanceOf = {
  19. GoodAsInstanceOf.super.<init>();
  20. ()
  21. };
  22. def takesTypeTag[A >: Nothing <: Any](a: A)(implicit evidence$1: reflect.runtime.universe.TypeTag[A]): String = {
  23. val tt: reflect.runtime.universe.TypeTag[A] = scala.this.Predef.implicitly[reflect.runtime.universe.TypeTag[A]](evidence$1);
  24. scala.StringContext.apply("The tt of A is ", "").s(tt)
  25. };
  26. def exerciseIt(): String = GoodAsInstanceOf.this.takesTypeTag[String]("Hello")({
  27. val $u: reflect.runtime.universe.type = scala.reflect.runtime.`package`.universe;
  28. val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(classOf[GoodAsInstanceOf].getClassLoader());
  29. $u.TypeTag.apply[String]($m, {
  30. final class $typecreator1 extends TypeCreator {
  31. def <init>(): $typecreator1 = {
  32. $typecreator1.super.<init>();
  33. ()
  34. };
  35. def apply[U >: Nothing <: scala.reflect.api.Universe with Singleton]($m$untyped: scala.reflect.api.Mirror[U]): U#Type = {
  36. val $u: U = $m$untyped.universe;
  37. val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
  38. $m.staticClass("java.lang.String").asType.toTypeConstructor
  39. }
  40. };
  41. new $typecreator1()
  42. })
  43. })
  44. }
  45. }
  46.  
  47. // Ignore usage in synthetic classes
  48. case ClassDef(_, _, _, _) if synthetic =>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement