Skip to content

Conversation

@hamzaremmal
Copy link
Member

@hamzaremmal hamzaremmal commented Nov 19, 2025

Based on @eejbyfeldt proposal in #24460. Thanks for the suggestion!


@eejbyfeldt I wasn't sure if you would be okay to include you as a co-author of the commit? Let me know and I will amend it.

@hamzaremmal hamzaremmal self-assigned this Nov 19, 2025
@hamzaremmal hamzaremmal added area:library Standard library needs-minor-release This PR cannot be merged until the next minor release labels Nov 19, 2025
* @param T ???
* @return ???
*/
transparent inline def as[T]: T = inline self match
Copy link
Member Author

@hamzaremmal hamzaremmal Nov 19, 2025

Choose a reason for hiding this comment

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

The name is not set in stone. I like as since it is short, to the point and it is not available unless we import it from the scala.compiletime. A suggestion during the LAMP meeting was to call it inlineAs.

@bishabosha
Copy link
Member

bishabosha commented Nov 19, 2025

no immediate no-gos - but would be useful to have more examples to see if it actually is useful as intended, and not under only very special circumstances

private inline def singletons[T, Elem <: Tuple]: Seq[T] =
inline erasedValue[Elem] match
case _: EmptyTuple => Seq.empty
case _: (h *: t) => valueOf[h](using summonInline).as[T] +: singletons[T, t]
Copy link
Member Author

Choose a reason for hiding this comment

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

After #23773, we should be able to write valueOf[h].as[T]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:library Standard library needs-minor-release This PR cannot be merged until the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants