Skip to content

Make -> sugar an inline method#24728

Open
bishabosha wants to merge 2 commits into
scala:mainfrom
dotty-staging:feat/inlined-arrow-assoc
Open

Make -> sugar an inline method#24728
bishabosha wants to merge 2 commits into
scala:mainfrom
dotty-staging:feat/inlined-arrow-assoc

Conversation

@bishabosha
Copy link
Copy Markdown
Member

@bishabosha bishabosha commented Dec 11, 2025

Must wait for 3.10.0

currently it is transparent inline, to avoid inline proxy objects appearing in capture sets and breaking type checking.
now it follows the design:

extension [A](inline self: A) inline def ->[B](inline that: B): (A, B) = (self, that)

based on #25175

requires to introduce the change in src-bootstrapped (until rebootstrapping)

fixes #24715

@bishabosha bishabosha added this to the 3.10.0 milestone Dec 11, 2025
@bishabosha bishabosha requested a review from a team as a code owner December 11, 2025 09:24
@bishabosha bishabosha added the needs-minor-release This PR cannot be merged until the next minor release label Dec 11, 2025
@bishabosha
Copy link
Copy Markdown
Member Author

bishabosha commented Dec 11, 2025

I made it transparent inline because this error shows up when only using inline: (see #24729)

[error] -- [E007] Type Mismatch Error: .../library/src/scala/collection/package.scala:71:16
[error]  71 |      else Some(t.head -> t.tail)
[error]     |                ^^^^^^^^^^^^^^^^
[error]     |      Found:    (A^'s1, C^{y$proxy1})
[error]     |      Required: (A, C)
[error]     |
[error]     |      Note that capability y$proxy1 is not included in capture set {}.
[error]     |---------------------------------------------------------------------------
[error]     |Inline stack trace
[error]     |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]     |This location contains code that was inlined from Predef.scala:616
[error] 616 |    inline def -> [B](y: B): (A, B) = (self, y)
[error]     |                                      ^^^^^^^^^
[error]      ---------------------------------------------------------------------------
[error]     |
[error]     | longer explanation available when compiling with `-explain`

@Gedochao Gedochao added the stat:feature freeze Issues and PRs waiting for the feature freeze to be lifted. label Dec 11, 2025
@bishabosha bishabosha force-pushed the feat/inlined-arrow-assoc branch from 73da792 to e62b7ae Compare December 11, 2025 10:00
Comment thread library/src/scala/Predef.scala Outdated
@bishabosha
Copy link
Copy Markdown
Member Author

bishabosha commented Dec 11, 2025

#24728 (comment) This should really be a non-transparent. If it bothers CC, then CC must adapt.

ok then lets say blocked by #24729

now thats fixed

inline def runtimeChecked: x.type @RuntimeChecked = x: @RuntimeChecked

// extension method sugar ---------------------------------------------
extension[A] (inline self: A)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe it's better to put it in the package object scala instead.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

scala package is really only for exporting forwarders is it not?
-> is an additional sugar

@Gedochao Gedochao removed the stat:feature freeze Issues and PRs waiting for the feature freeze to be lifted. label May 27, 2026
@Gedochao
Copy link
Copy Markdown
Contributor

@bishabosha might be worth a rebase, we're entering 3.10.

@bishabosha bishabosha force-pushed the feat/inlined-arrow-assoc branch from f3da9d9 to 6567d1d Compare May 29, 2026 16:58
@bishabosha
Copy link
Copy Markdown
Member Author

@Gedochao rebased

@bishabosha bishabosha force-pushed the feat/inlined-arrow-assoc branch from 7dc413f to 830590e Compare May 29, 2026 17:30
@bishabosha
Copy link
Copy Markdown
Member Author

potential problem, it looks like in 830590e that trying to import from Predef explicitly will bias in favor of ArrowAssoc and cause deprecation warning, and then it isnt possible to unimport ArrowAssoc => _ without typer no longer resolving -> extension method

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

Labels

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.

Verbose bytecode generated for the creation of a single tuple via ->

4 participants