You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I thought I would need to use the Symbol's signature to get the type but I don't see a lot of documentation for signature or how to access type information (such as individually selecting types from higher orders, such as List[Int], as enabled in scala 2 by typeSignature or scala.reflect.macros.Context.typeCheck).
So can someone please clarify how tree or signature can be used to get detailed type information for each case class field?
Thanks!
The text was updated successfully, but these errors were encountered:
// for a cc field of type Map[String, List[Int]], this gives you:// Map, String, and List TypeReprs// recursion may be necessary to get List[Int]: https://stackoverflow.com/a/69073868/1080804valtypeParams:List[TypeRepr] = ccField.owner.typeRef.memberType(ccField) match {
// from: https://docs.scala-lang.org/scala3/guides/contribution/arch-types.htmlcaseAppliedType(thisType, args) =>List(thisType) ++ args
case _ =>Nil
}
valsimpleStrings= typeParams.map(_.typeSymbol.fullName)
Hi,
I think this defaultParamsInference is a great example I'd like to extend further to include the type of each case class field.
What amazes me is I didn't realize you can cast a
Tree
as you do here:https://github.com/lampepfl/dotty-macro-examples/blob/main/defaultParamsInference/src/macro.scala#L18
I thought I would need to use the Symbol's
signature
to get the type but I don't see a lot of documentation forsignature
or how to access type information (such as individually selecting types from higher orders, such asList[Int]
, as enabled in scala 2 bytypeSignature
orscala.reflect.macros.Context.typeCheck
).So can someone please clarify how
tree
orsignature
can be used to get detailed type information for each case class field?Thanks!
The text was updated successfully, but these errors were encountered: