Skip to content

Commit e62b7ae

Browse files
committed
Make -> sugar an inline method
Must wait for 3.10.0 currently it is transparent inline, to avoid inline proxy objects appearing in capture sets and breaking type checking.
1 parent ba45875 commit e62b7ae

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

library/src/scala/Predef.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,9 @@ object Predef extends LowPriorityImplicits {
389389
// implicit classes -----------------------------------------------------
390390

391391
/** @group implicit-classes-any */
392+
@deprecated("Use `->` extension method instead.", since = "3.10.0")
392393
implicit final class ArrowAssoc[A](private val self: A) extends AnyVal {
394+
@deprecated("Use `->` extension method instead.", since = "3.10.0")
393395
@inline def -> [B](y: B): (A, B) = (self, y)
394396
@deprecated("Use `->` instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.", "2.13.0")
395397
def [B](y: B): (A, B) = ->(y)
@@ -609,6 +611,11 @@ object Predef extends LowPriorityImplicits {
609611
*/
610612
inline def runtimeChecked: x.type @RuntimeChecked = x: @RuntimeChecked
611613

614+
// extension method sugar ---------------------------------------------
615+
extension[A] (self: A)
616+
transparent inline def -> [B](y: B): (A, B) = (self, y)
617+
618+
612619
}
613620

614621
/** The `LowPriorityImplicits` class provides implicit values that

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionExtensionSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,7 @@ class CompletionExtensionSuite extends BaseCompletionSuite:
453453
"""|baz(): Unit
454454
|copy(): Bar
455455
|qux: Unit
456+
|->[B](y: B): (Bar, B)
456457
|asInstanceOf[X0]: X0
457458
|canEqual(that: Any): Boolean
458459
|equals(x$0: Any): Boolean
@@ -467,7 +468,6 @@ class CompletionExtensionSuite extends BaseCompletionSuite:
467468
|productPrefix: String
468469
|synchronized[X0](x$0: X0): X0
469470
|toString(): String
470-
|->[B](y: B): (Bar, B)
471471
|ensuring(cond: Boolean): Bar
472472
|ensuring(cond: Bar => Boolean): Bar
473473
|ensuring(cond: Boolean, msg: => Any): Bar

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class CompletionSuite extends BaseCompletionSuite:
109109
|tabulate[A](n: Int)(f: Int => A): List[A]
110110
|unapplySeq[A](x: List[A] @uncheckedVariance): UnapplySeqWrapper[A]
111111
|unfold[A, S](init: S)(f: S => Option[(A, S)]): List[A]
112+
|->[B](y: B): (List.type, B)
112113
|fromSpecific(from: Any)(it: IterableOnce[Nothing]): List[Nothing]
113114
|fromSpecific(it: IterableOnce[Nothing]): List[Nothing]
114115
|toFactory(from: Any): Factory[Nothing, List[Nothing]]
@@ -120,7 +121,6 @@ class CompletionSuite extends BaseCompletionSuite:
120121
|isInstanceOf[X0]: Boolean
121122
|synchronized[X0](x$0: X0): X0
122123
|toString(): String
123-
|->[B](y: B): (List.type, B)
124124
|ensuring(cond: Boolean): List.type
125125
|ensuring(cond: List.type => Boolean): List.type
126126
|ensuring(cond: Boolean, msg: => Any): List.type

0 commit comments

Comments
 (0)