question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ident factory in Quotes

See original GitHub issue

The Ident type is exposed in Quotes.reflectModule API, but I don’t see a function in IdentModule (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: https://github.com/cchantep/dotty/commit/a4c3dcfe8f0fa7a685a46da67aa322443206e61b#diff-42ea4b504ef08605734e689ebe8e3aed413718879873e2eff4951dbed4dc8da0R430 ).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolasstuckicommented, Apr 27, 2021

To create case foo: MyType => foo you will need something like

      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)))
0reactions
cchantepcommented, Nov 21, 2021

BTW it seems weird that to emit a case x: String => () it’s not possible to use:

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 as below.

CaseDef(
  Bind(bind, Typed(Wildcard(), Inferred(tpr))),
  guard = None,
  rhs = Block(Nil, Literal(UnitConstant()))
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

75 Inspirational Manufacturing Quotes That Will Boost ...
Some of the greatest leaders of industry and manufacturing offer inspiration for revitalizing, improving, and impacting your business.
Read more >
Factory Quotes - Goodreads
“I'm a fake fact factory. The things I make are the things I make up. Also, as a side business, I make love....
Read more >
22 Best Branding Quotes to Inspire You - 99Designs
Your brand identity is your chance to set yourself and your business apart from the competition, so make the most of it. The...
Read more >
13 Motivational Quotes for Design and Manufacturing
The main takeaway from the below insights is pretty simple, after all: work hard, learn from your failures and continue striving for excellence!...
Read more >
The 50 Best PR Quotes of All Time - The Content Factory
“If a young man tells his date how handsome, smart and successful he is – that's advertising. If the young man tells his...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found