-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Ident factory in Quotes #12237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
An alternative is to use Before creating an ident it is necessary to resolve to what Creating a new symbol an returning an ident will not work and this ident points to a symbol/definition that does not exist in the program (i.e. there is not |
Thanks for your feedback. |
Which |
To create val owner = Symbol.spliceOwner
val tpe = TypeRepr.of[MyType]
val bind = Symbol.newBind(owner, "foo", Flags.Case, tpe)
CaseDef(Bind(bind, Typed(Ref(bind), Inferred(tpe))), None, Ref(bind))) |
Thanks for your feedback. As far as I see, the |
I think there is a similar lack of utility, to resolve a |
BTW it seems weird that to emit a val tpr = TypeRepr.of[String]
val bind =
Symbol.newBind(
Symbol.spliceOwner,
tpr.typeSymbol.name.toLowerCase,
Flags.Case,
tpr
)
val br = Ref(bind)
CaseDef(Typed(br, Inferred(tpr)), guard = None, rhs = UnitConstant())
/* Compilation error:
While expanding a macro, a reference to value string was used outside the scope where it was defined
*/ Indeed it seems required to write the CaseDef(
Bind(bind, Typed(Wildcard(), Inferred(tpr))),
guard = None,
rhs = Block(Nil, Literal(UnitConstant()))
) |
The
Ident
type is exposed inQuotes.reflectModule
API, but I don't see a function inIdentModule
(or elsewhere) provided to create such a value for a term name (is there anything I missed?).Some simple factory like
Ident("foo", ...)
would be nice (and seems possible: cchantep@a4c3dcf#diff-42ea4b504ef08605734e689ebe8e3aed413718879873e2eff4951dbed4dc8da0R430 ).The text was updated successfully, but these errors were encountered: