Created
January 31, 2023 23:36
-
-
Save erikerlandson/55b898efde4436e986a63741ffb730a2 to your computer and use it in GitHub Desktop.
get the value type of a scala 3 symbol as a TypeRepr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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