def makeTupleType(using Quotes)(items: List[Key]): TypeRepr =
import quotes.reflect.*
val typeRefs = items.map { item =>
val path = "me.chuwy.Example.Namespace.Key.$item"
Symbol.requiredModule(path).termRef // Tried different variations
}
defn.TupleClass(typeRefs.length).typeRef.dealias.appliedTo(typeRefs) // works for 1+ arity
All Keys are elements of an enum:
package me.chuwy
object Example:
object Namespace:
enum Key:
case One
case Two
case Three
What I want in the end is something like Tuple2[One.type, Three.type], but the problem is that I cannot find a way for a Symbol to find the TermRef - the best I could get is Tuple2[Key, Key]. How do I get TermRefs for enum cases?
I’m basically stuck with classes in the path. I can make Example an object, but as soon as I call fieldMember - Example becomes a class. Tried companionModule, but it gives the same result.
Ok, actually it seems the problem was in a different place. Just my code was not compiling without sensible errors and everything pointed to this macro - solved it now. Thank you very much!