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/neg/logImplicits.check | 4 ++-- test/files/presentation/callcc-interpreter.check | 6 +---- test/files/presentation/ide-bug-1000349.check | 6 +---- test/files/presentation/ide-bug-1000475.check | 18 +++----------- test/files/presentation/ide-bug-1000531.check | 6 +---- test/files/presentation/implicit-member.check | 6 +---- test/files/presentation/ping-pong.check | 12 ++-------- test/files/presentation/t5708.check | 6 +---- test/files/presentation/visibility.check | 30 ++++-------------------- 9 files changed, 17 insertions(+), 77 deletions(-) (limited to 'test/files') diff --git a/test/files/neg/logImplicits.check b/test/files/neg/logImplicits.check index 0522bd8354..2265614962 100644 --- a/test/files/neg/logImplicits.check +++ b/test/files/neg/logImplicits.check @@ -7,10 +7,10 @@ logImplicits.scala:7: applied implicit conversion from String("abc") to ?{def ma logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String("abc"))Int math.max(122, x: Int) ^ -logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def ArrowAssoc[A](__leftOfArrow: A): ArrowAssoc[A] +logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def ArrowAssoc[A](self: A): ArrowAssoc[A] def f = (1 -> 2) + "c" ^ -logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{def +: ?} = implicit def StringAdd[A](__thingToAdd: A): StringAdd[A] +logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{def +: ?} = implicit def StringAdd[A](self: A): StringAdd[A] def f = (1 -> 2) + "c" ^ logImplicits.scala:22: error: class Un needs to be abstract, since method unimplemented is not defined diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index 59c841a255..d41b982614 100644 --- a/test/files/presentation/callcc-interpreter.check +++ b/test/files/presentation/callcc-interpreter.check @@ -3,7 +3,7 @@ reload: CallccInterpreter.scala askTypeCompletion at CallccInterpreter.scala(51,38) ================================================================================ [response] askCompletionAt (51,38) -retrieved 63 members +retrieved 59 members abstract trait Term extends AnyRef abstract trait Value extends AnyRef case class Add extends callccInterpreter.Term with Product with Serializable @@ -52,10 +52,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: callccInterpreter.type -private[this] val __resultOfEnsuring: callccInterpreter.type -private[this] val __stringToFormat: callccInterpreter.type -private[this] val __thingToAdd: callccInterpreter.type private[this] val term0: callccInterpreter.App private[this] val term1: callccInterpreter.App private[this] val term2: callccInterpreter.Add diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check index b15486f4ac..aa6660cec5 100644 --- a/test/files/presentation/ide-bug-1000349.check +++ b/test/files/presentation/ide-bug-1000349.check @@ -3,7 +3,7 @@ reload: CompletionOnEmptyArgMethod.scala askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17) ================================================================================ [response] askCompletionAt (2,17) -retrieved 36 members +retrieved 32 members def +(other: String): String def ->[B](y: B): (Foo, B) def ensuring(cond: Boolean): Foo @@ -31,10 +31,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: Foo -private[this] val __resultOfEnsuring: Foo -private[this] val __stringToFormat: Foo -private[this] val __thingToAdd: Foo protected[package lang] def clone(): Object protected[package lang] def finalize(): Unit ================================================================================ diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check index e4b8508846..cb7de6d34a 100644 --- a/test/files/presentation/ide-bug-1000475.check +++ b/test/files/presentation/ide-bug-1000475.check @@ -3,7 +3,7 @@ reload: Foo.scala askTypeCompletion at Foo.scala(3,7) ================================================================================ [response] askCompletionAt (3,7) -retrieved 35 members +retrieved 31 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit def +(other: String): String @@ -32,16 +32,12 @@ 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: Object -private[this] val __resultOfEnsuring: Object -private[this] val __stringToFormat: Object -private[this] val __thingToAdd: Object ================================================================================ askTypeCompletion at Foo.scala(6,10) ================================================================================ [response] askCompletionAt (6,10) -retrieved 35 members +retrieved 31 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit def +(other: String): String @@ -70,16 +66,12 @@ 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: Object -private[this] val __resultOfEnsuring: Object -private[this] val __stringToFormat: Object -private[this] val __thingToAdd: Object ================================================================================ askTypeCompletion at Foo.scala(7,7) ================================================================================ [response] askCompletionAt (7,7) -retrieved 35 members +retrieved 31 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit def +(other: String): String @@ -108,8 +100,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: Object -private[this] val __resultOfEnsuring: Object -private[this] val __stringToFormat: Object -private[this] val __thingToAdd: Object ================================================================================ diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index be8805330a..9a2cad5fd2 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -3,7 +3,7 @@ reload: CrashOnLoad.scala askTypeCompletion at CrashOnLoad.scala(6,12) ================================================================================ [response] askCompletionAt (6,12) -retrieved 124 members +retrieved 120 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit [inaccessible] protected[this] def reversed: List[B] @@ -121,8 +121,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: java.util.Iterator[B] -private[this] val __resultOfEnsuring: java.util.Iterator[B] -private[this] val __stringToFormat: java.util.Iterator[B] -private[this] val __thingToAdd: java.util.Iterator[B] ================================================================================ diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check index acf7e1a0fd..ef361599c5 100644 --- a/test/files/presentation/implicit-member.check +++ b/test/files/presentation/implicit-member.check @@ -3,7 +3,7 @@ reload: ImplicitMember.scala askTypeCompletion at ImplicitMember.scala(7,7) ================================================================================ [response] askCompletionAt (7,7) -retrieved 38 members +retrieved 34 members def +(other: String): String def ->[B](y: B): (Implicit.type, B) def ensuring(cond: Boolean): Implicit.type @@ -32,10 +32,6 @@ final def wait(): Unit final def wait(x$1: Long): Unit final def wait(x$1: Long,x$2: Int): Unit implicit def AppliedImplicit[A](x: A): Implicit.AppliedImplicit[A] -private[this] val __leftOfArrow: Implicit.type -private[this] val __resultOfEnsuring: Implicit.type -private[this] val __stringToFormat: Implicit.type -private[this] val __thingToAdd: Implicit.type private[this] val x: Implicit.type protected[package lang] def clone(): Object protected[package lang] def finalize(): Unit diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check index be80601e11..10d29bfed6 100644 --- a/test/files/presentation/ping-pong.check +++ b/test/files/presentation/ping-pong.check @@ -3,7 +3,7 @@ reload: PingPong.scala askTypeCompletion at PingPong.scala(10,23) ================================================================================ [response] askCompletionAt (10,23) -retrieved 39 members +retrieved 35 members [inaccessible] private[this] val ping: Ping [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit @@ -34,17 +34,13 @@ final def wait(): Unit final def wait(x$1: Long): Unit final def wait(x$1: Long,x$2: Int): Unit override def toString(): String -private[this] val __leftOfArrow: Pong -private[this] val __resultOfEnsuring: Pong -private[this] val __stringToFormat: Pong -private[this] val __thingToAdd: Pong private[this] val name: String ================================================================================ askTypeCompletion at PingPong.scala(19,20) ================================================================================ [response] askCompletionAt (19,20) -retrieved 39 members +retrieved 35 members [inaccessible] protected[package lang] def clone(): Object [inaccessible] protected[package lang] def finalize(): Unit def +(other: String): String @@ -76,10 +72,6 @@ final def wait(): Unit final def wait(x$1: Long): Unit final def wait(x$1: Long,x$2: Int): Unit override def toString(): String -private[this] val __leftOfArrow: Ping -private[this] val __resultOfEnsuring: Ping -private[this] val __stringToFormat: Ping -private[this] val __thingToAdd: Ping private[this] val pong: Pong ================================================================================ diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check index b2cedd689f..5f17c0b762 100644 --- a/test/files/presentation/t5708.check +++ b/test/files/presentation/t5708.check @@ -3,7 +3,7 @@ reload: Completions.scala askTypeCompletion at Completions.scala(17,9) ================================================================================ [response] askCompletionAt (17,9) -retrieved 43 members +retrieved 39 members [inaccessible] private def privateM: String [inaccessible] private[this] val privateV: String [inaccessible] private[this] val protectedV: String @@ -39,9 +39,5 @@ final def wait(x$1: Long,x$2: Int): Unit final private[this] val CONST_STRING: String("constant") lazy private[this] var foo: Int private[package test] def pkgPrivateM: String -private[this] val __leftOfArrow: test.Compat.type -private[this] val __resultOfEnsuring: test.Compat.type -private[this] val __stringToFormat: test.Compat.type -private[this] val __thingToAdd: test.Compat.type private[this] val pkgPrivateV: String ================================================================================ 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