Skip to content

Fix example code from How to write a type class derived method using macros #10382

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

Merged
merged 3 commits into from
Nov 19, 2020

Conversation

ghostdogpr
Copy link
Contributor

Closes #10381

@ghostdogpr
Copy link
Contributor Author

(I just signed the CLA)

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! @nicolasstucki Can you double-check that this is still a good example for the documentation?

Copy link
Contributor

@nicolasstucki nicolasstucki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I just added a couple of extra simplification.

@nicolasstucki
Copy link
Contributor

Thank you @ghostdogpr

@nicolasstucki nicolasstucki merged commit b7be482 into scala:master Nov 19, 2020
case '[String *: $tpes] => '{ summon[Eq[String]] } :: summonAll(tpes)
case '[Int *: $tpes] => '{ summon[Eq[Int]] } :: summonAll(tpes)
case '[$tpe *: $tpes] => derived(using tpe, qctx) :: summonAll(tpes)
def summonAll[T: Type](using qctx: QuoteContext): List[Expr[Eq[_]]] = t match {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolasstucki Does this actually compile? I don't see where t is defined here. Also if we update the doc we should keep the test case synchronized: https://github.com/lampepfl/dotty/blob/master/tests/run-macros/i8007/Macro_3.scala

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that. I will fix it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix in #10395

@ghostdogpr ghostdogpr deleted the patch-1 branch November 20, 2020 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code from docs does not compile (typeclass derivation with macros)
3 participants