Oddbean new post about | logout
 @db915dd6 You can have access to type information, yes. That requires to have a `A: Type` implicit in the macro's definition to workaround erasure.

In that sample, I can define Caller[A], but it may not help for my use-case because my function call will be without types, so it will infer it as `Any`, anyway.

I tried working around that with `transparent`, but for now, I don't really know what I'm doing. Trying to find more resources. 
 @54814b2f So is A: Type mean that metadata is kept around at runtime? Guess I'm asking if you have compile time only type reflection. 
 @db915dd6 Ah, in this case it's all compile time, Type being an intrinsic.

You do have quite powerful compile-time reflection. For one there is ClassTag – this is weaker, but it allows you to create reified Arrays.

https://scala-lang.org/api/3.3.1/scala/reflect/ClassTag.html

Scala 2.x had TypeTag, with everything, but it was exposing compiler info so it was removed. You can use ClassTag for more depth, like what I did here, e.g.:

https://github.com/monix/newtypes/blob/main/core/shared/src/main/scala/monix/newtypes/TypeInfo.scala

Or smth like this is probably more complete: https://github.com/zio/izumi-reflect 
 @54814b2f But it looks like you still need RTTI? Admittedly I don't know much about this part of Scala so I'll investigate further. Thanks! 
 @db915dd6 ClassTag can give you a Class, which the JVM needs, so yes, that's related to RTTI, but the ClassTag itself is generated by the compiler. I mentioned ClassTag because it's the easiest to use, and you basically get the equivalent of C#'s reification.

That library, izumi-reflect, doesn't have anything to do with a RTTI. All type info is exposed in macros, but AFAIK it's no longer easily accessible as a TypeTag, so you have to write a macro to get it 🤷‍♂️ 
 @db915dd6 BTW, one pretty good development is that you can derive type class instances pretty easily, and you only need "inline" functions with no macros, just compile-time reflection via implicits, which can deconstruct sum and product types.