Skip to content
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

Support inline unapplySeq and with leading given parameters #16358

Merged
merged 2 commits into from
Dec 7, 2022

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Nov 17, 2022

Based on #15191 by @gorilskij and enables support for #12991.

Fixes #8577
Fixes #12991
Fixes #15188

@nicolasstucki nicolasstucki force-pushed the fix-15191 branch 2 times, most recently from 6cbb190 to ee5283f Compare November 18, 2022 09:25
@nicolasstucki nicolasstucki marked this pull request as ready for review November 18, 2022 12:19
@nicolasstucki nicolasstucki changed the title Support inline inline unapplySeq and with leading given parameters Support inline unapplySeq and inline with leading given parameters Nov 18, 2022
@nicolasstucki nicolasstucki changed the title Support inline unapplySeq and inline with leading given parameters Support inline unapplySeq and with leading given parameters Nov 18, 2022
case TypeApply(_, targs) => targs
case _ => Nil
val unapplyInfo = sym.info match
case info: PolyType => info.instantiate(targs.map(_.tpe))
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this needed anymore? The comment above could maybe explain how type parameters are handled.

Choose a reason for hiding this comment

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

That's handled by fun.tpe.widen (line 202)

Copy link
Contributor Author

@nicolasstucki nicolasstucki Dec 7, 2022

Choose a reason for hiding this comment

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

I added a comment below and managed to simplify the leading implicits logic thanks to the use of fun.tpe.widen.

Now it even works with something as complex as

  extension [T] (using A)(inline ctx: Macro.StrCtx)(using B) inline def unapplySeq[U](using C)(inline input: T)(using D)(using F): Option[Seq[T]] = ???

* Fixes the computation of the inline unapply temporary unanimous unapply placeholder
* Handle leading given parameters in inline unapplies

Fixes scala#8577
Fixes scala#12991
Fixes scala#15188
@nicolasstucki nicolasstucki requested a review from smarter December 7, 2022 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants