Skip to content

Instantly share code, notes, and snippets.

@erikerlandson
Created January 31, 2023 23:36
Show Gist options
  • Save erikerlandson/55b898efde4436e986a63741ffb730a2 to your computer and use it in GitHub Desktop.
Save erikerlandson/55b898efde4436e986a63741ffb730a2 to your computer and use it in GitHub Desktop.
get the value type of a scala 3 symbol as a TypeRepr
def symbolValueType(using Quotes)(
sym: quotes.reflect.Symbol
): quotes.reflect.TypeRepr =
import quotes.reflect.*
val TermRef(tr, _) = sym.termRef: @unchecked
// widen is important here otherwise you may get singleton or by-name types
tr.memberType(sym).widen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment