From e2a34984527c0437cd42476934d0c22164551eed Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 17 Oct 2013 14:15:28 +0200 Subject: Make parameters to implicit value classes private So that they aren't offered as an autocomplete suggestion: implicit class Shouty(string: String) extends AnyVal { def SHOUT_! = string.toUpperCase + "!" } "". // autocompletion offers `.string` here The original incarnation of value classes didn't allow this sort of encapsulation, so we either invented goofy names like `__thingToAdd` or just picked `x` or `self`. But SI-7859 has delivered us the freedom to keep the accessor private. Should we keep any of these accessors around in a deprecated form? The implicit classes in Predef were added in 2.11.0-M2 (c26a8db067e4f), so they are okay. I think we can make reason that these APIs were both accidental and unlikely to be interpreted as public, so we can break them immediately. scala> Left(1).x res0: scala.util.Either[Int,Int] = Left(1) scala> import concurrent.duration._ import concurrent.duration._ scala> 1.n res1: Int = 1 --- test/files/presentation/visibility.check | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) (limited to 'test/files/presentation/visibility.check') diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check index 4ba7dbaad9..078e0a2342 100644 --- a/test/files/presentation/visibility.check +++ b/test/files/presentation/visibility.check @@ -3,7 +3,7 @@ reload: Completions.scala askTypeCompletion at Completions.scala(14,12) ================================================================================ [response] askCompletionAt (14,12) -retrieved 41 members +retrieved 37 members [inaccessible] private[this] def secretPrivateThis(): Unit def +(other: String): String def ->[B](y: B): (accessibility.Foo, B) @@ -34,10 +34,6 @@ final def wait(): Unit final def wait(x$1: Long): Unit final def wait(x$1: Long,x$2: Int): Unit private def secretPrivate(): Unit -private[this] val __leftOfArrow: accessibility.Foo -private[this] val __resultOfEnsuring: accessibility.Foo -private[this] val __stringToFormat: accessibility.Foo -private[this] val __thingToAdd: accessibility.Foo protected def secretProtected(): Unit protected[package accessibility] def secretProtectedInPackage(): Unit protected[package lang] def clone(): Object @@ -47,7 +43,7 @@ protected[package lang] def finalize(): Unit askTypeCompletion at Completions.scala(16,11) ================================================================================ [response] askCompletionAt (16,11) -retrieved 41 members +retrieved 37 members def +(other: String): String def ->[B](y: B): (accessibility.Foo, B) def ensuring(cond: Boolean): accessibility.Foo @@ -78,10 +74,6 @@ final def wait(x$1: Long): Unit final def wait(x$1: Long,x$2: Int): Unit private def secretPrivate(): Unit private[this] def secretPrivateThis(): Unit -private[this] val __leftOfArrow: accessibility.Foo -private[this] val __resultOfEnsuring: accessibility.Foo -private[this] val __stringToFormat: accessibility.Foo -private[this] val __thingToAdd: accessibility.Foo protected def secretProtected(): Unit protected[package accessibility] def secretProtectedInPackage(): Unit protected[package lang] def clone(): Object @@ -91,7 +83,7 @@ protected[package lang] def finalize(): Unit askTypeCompletion at Completions.scala(22,11) ================================================================================ [response] askCompletionAt (22,11) -retrieved 41 members +retrieved 37 members [inaccessible] private def secretPrivate(): Unit def +(other: String): String def ->[B](y: B): (accessibility.AccessibilityChecks, B) @@ -122,10 +114,6 @@ final def synchronized[T0](x$1: T0): T0 final def wait(): Unit final def wait(x$1: Long): Unit final def wait(x$1: Long,x$2: Int): Unit -private[this] val __leftOfArrow: accessibility.AccessibilityChecks -private[this] val __resultOfEnsuring: accessibility.AccessibilityChecks -private[this] val __stringToFormat: accessibility.AccessibilityChecks -private[this] val __thingToAdd: accessibility.AccessibilityChecks protected def secretProtected(): Unit protected[package accessibility] def secretProtectedInPackage(): Unit protected[package lang] def clone(): Object @@ -135,7 +123,7 @@ protected[package lang] def finalize(): Unit askTypeCompletion at Completions.scala(28,10) ================================================================================ [response] askCompletionAt (28,10) -retrieved 41 members +retrieved 37 members [inaccessible] private def secretPrivate(): Unit [inaccessible] private[this] def secretPrivateThis(): Unit [inaccessible] protected def secretProtected(): Unit @@ -169,17 +157,13 @@ final def synchronized[T0](x$1: T0): T0 final def wait(): Unit final def wait(x$1: Long): Unit final def wait(x$1: Long,x$2: Int): Unit -private[this] val __leftOfArrow: accessibility.Foo -private[this] val __resultOfEnsuring: accessibility.Foo -private[this] val __stringToFormat: accessibility.Foo -private[this] val __thingToAdd: accessibility.Foo protected[package accessibility] def secretProtectedInPackage(): Unit ================================================================================ askTypeCompletion at Completions.scala(37,8) ================================================================================ [response] askCompletionAt (37,8) -retrieved 41 members +retrieved 37 members [inaccessible] private def secretPrivate(): Unit [inaccessible] private[this] def secretPrivateThis(): Unit [inaccessible] protected def secretProtected(): Unit @@ -214,8 +198,4 @@ final def synchronized[T0](x$1: T0): T0 final def wait(): Unit final def wait(x$1: Long): Unit final def wait(x$1: Long,x$2: Int): Unit -private[this] val __leftOfArrow: accessibility.Foo -private[this] val __resultOfEnsuring: accessibility.Foo -private[this] val __stringToFormat: accessibility.Foo -private[this] val __thingToAdd: accessibility.Foo ================================================================================ -- cgit v1.2.3