-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chore: deprecate scala.util.ChainingOps
#24725
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
base: main
Are you sure you want to change the base?
Conversation
| @nowarn("msg=ChainingSyntax will be removed in the future") | ||
| object chaining extends ChainingSyntax: | ||
| extension[A](x: A) | ||
| inline def tap(inline f: A => Unit): x.type = { f(x); x } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The signature here differs from the one we used to have in scala.util.ChainingOps. First, we return a more precise type: x.type. Second, we do not need to have a second type variable and specify that f: A => B since we adapt the body of the lambda after the eta-expansion. This code will compile because of the adaptation for example:
def foo(x: String): String = "()"
val x: String => Unit = foo
def bar(f: String => Unit) = ()
bar(foo)
bar(x)| f(self) | ||
| self | ||
| } | ||
| def tap[U](f: A => U): A = scala.util.chaining.tap(self)(x => f(x)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| def tap[U](f: A => U): A = scala.util.chaining.tap(self)(x => f(x)) | |
| def tap[U](f: A => U): A = scala.util.chaining.tap(self)(f) |
But it is blocked by #24726
c7494fb to
6aee5bd
Compare
| */ | ||
| object chaining extends ChainingSyntax | ||
| @nowarn("msg=ChainingSyntax will be removed in the future") | ||
| object chaining extends ChainingSyntax: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question for me: Can we move this object to be outside the package object util?
|
This PR's communication is off. The value added by the first commit is that Even more so, the second commit adds a public method to the API. There is no world in which this should be categorized as "chore". This is the archetypical "feat" according to any such categorization. |
| @nowarn("msg=ChainingSyntax will be removed in the future") | ||
| object chaining extends ChainingSyntax: | ||
| extension[A](x: A) | ||
| inline def tap(inline f: A => Unit): x.type = { f(x); x } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you don't want to break imports like import scala.util.chaining.given then you can put these in a given AnyRef:
No description provided.