blob: 692c768f26e8759ce33af11ed62a837c9299dfd9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import scala.reflect.runtime.universe._
import scala.reflect.runtime.{currentMirror => cm}
import scala.reflect.{ClassTag, classTag}
object Test extends dotty.runtime.LegacyApp {
def test[T: ClassTag: TypeTag](x: T) = {
println(s"========${classTag[T].runtimeClass}========")
println(cm.reflect(x).reflectMethod(typeOf[T].member(TermName("getClass")).asMethod)())
println(cm.reflect(x).reflectMethod(typeOf[T].member(TermName("toString")).asMethod)())
}
test(2.toByte)
test(2.toShort)
test(2.toInt)
test(2.toLong)
test(2.toFloat)
test(2.toDouble)
test('2')
test(true)
test(())
}
|