Skip to content

Commit c2a1324

Browse files
committed
Merge pull request scala#3113 from adriaanm/pr-rebase-3046
Make parameters to implicit value classes private
2 parents 8bed4a8 + e2a3498 commit c2a1324

File tree

14 files changed

+63
-101
lines changed

14 files changed

+63
-101
lines changed

build.xml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,13 @@ TODO:
286286
-->
287287
<!-- <artifact:remoteRepository refid="extra-repo"/> -->
288288
<dependency groupId="org.scala-lang.modules" artifactId="scala-partest_${scala.binary.version}" version="${partest.version.number}" />
289-
<dependency groupId="org.scalacheck" artifactId="scalacheck_${scala.binary.version}" version="${scalacheck.version.number}" />
290289
</artifact:dependencies>
291290
<copy-deps project="partest"/>
292291

292+
<artifact:dependencies pathId="scalacheck.classpath" filesetId="scalacheck.fileset" versionsId="scalacheck.versions">
293+
<dependency groupId="org.scalacheck" artifactId="scalacheck_${scala.binary.version}" version="${scalacheck.version.number}" />
294+
</artifact:dependencies>
295+
293296
<artifact:dependencies pathId="repl.deps.classpath" filesetId="repl.fileset" versionsId="repl.deps.versions">
294297
<dependency groupId="jline" artifactId="jline" version="${jline.version}"/>
295298
</artifact:dependencies>
@@ -894,11 +897,30 @@ TODO:
894897
<pathelement location="${actors.jar}"/>
895898

896899
<!-- partest's dependencies, which marks most of its dependencies as provided,
900+
(but not scala-library, so we filter that one out...)
897901
so we provide them: scala-[library/reflect/compiler], scalap built here,
898902
scala-xml, scala-parser-combinators via external-modules-nocore,
899903
scalacheck as part of `partest.classpath` -->
900-
<path refid="partest.classpath"/>
901-
<path refid="external-modules-nocore"/> <!-- xml, parsers -->
904+
<restrict>
905+
<path refid="partest.classpath"/>
906+
<rsel:not><rsel:or>
907+
<rsel:name name="scala-library*.jar"/>
908+
</rsel:or></rsel:not>
909+
</restrict>
910+
<pathelement location="${scala-xml}"/>
911+
<pathelement location="${scala-parser-combinators}"/>
912+
913+
<restrict>
914+
<path refid="scalacheck.classpath"/>
915+
<rsel:not><rsel:or>
916+
<rsel:name name="scala-library*.jar"/>
917+
<rsel:name name="scala-compiler*.jar"/>
918+
<rsel:name name="scala-reflect*.jar"/>
919+
<rsel:name name="scala-actors*.jar"/>
920+
<rsel:name name="scala-parser-combinators*.jar"/>
921+
<rsel:name name="scala-xml*.jar"/>
922+
</rsel:or></rsel:not>
923+
</restrict>
902924

903925
<!-- partest classes specific to the core compiler build -->
904926
<pathelement location="${partest-extras.jar}"/>

src/compiler/scala/tools/nsc/util/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ package object util {
7575
s"$clazz$msg @ $frame"
7676
}
7777

78-
implicit class StackTraceOps(val e: Throwable) extends AnyVal with StackTracing {
78+
implicit class StackTraceOps(private val e: Throwable) extends AnyVal with StackTracing {
7979
/** Format the stack trace, returning the prefix consisting of frames that satisfy
8080
* a given predicate.
8181
* The format is similar to the typical case described in the JavaDoc

src/library/scala/Predef.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -244,33 +244,33 @@ object Predef extends LowPriorityImplicits with DeprecatedPredef {
244244

245245
// implicit classes -----------------------------------------------------
246246

247-
implicit final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal {
248-
@inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y)
247+
implicit final class ArrowAssoc[A](private val self: A) extends AnyVal {
248+
@inline def -> [B](y: B): Tuple2[A, B] = Tuple2(self, y)
249249
def [B](y: B): Tuple2[A, B] = ->(y)
250250
}
251251

252-
implicit final class Ensuring[A](val __resultOfEnsuring: A) extends AnyVal {
253-
def ensuring(cond: Boolean): A = { assert(cond); __resultOfEnsuring }
254-
def ensuring(cond: Boolean, msg: => Any): A = { assert(cond, msg); __resultOfEnsuring }
255-
def ensuring(cond: A => Boolean): A = { assert(cond(__resultOfEnsuring)); __resultOfEnsuring }
256-
def ensuring(cond: A => Boolean, msg: => Any): A = { assert(cond(__resultOfEnsuring), msg); __resultOfEnsuring }
252+
implicit final class Ensuring[A](private val self: A) extends AnyVal {
253+
def ensuring(cond: Boolean): A = { assert(cond); self }
254+
def ensuring(cond: Boolean, msg: => Any): A = { assert(cond, msg); self }
255+
def ensuring(cond: A => Boolean): A = { assert(cond(self)); self }
256+
def ensuring(cond: A => Boolean, msg: => Any): A = { assert(cond(self), msg); self }
257257
}
258258

259-
implicit final class StringFormat[A](val __stringToFormat: A) extends AnyVal {
259+
implicit final class StringFormat[A](private val self: A) extends AnyVal {
260260
/** Returns string formatted according to given `format` string.
261261
* Format strings are as for `String.format`
262262
* (@see java.lang.String.format).
263263
*/
264-
@inline def formatted(fmtstr: String): String = fmtstr format __stringToFormat
264+
@inline def formatted(fmtstr: String): String = fmtstr format self
265265
}
266266

267-
implicit final class StringAdd[A](val __thingToAdd: A) extends AnyVal {
268-
def +(other: String) = String.valueOf(__thingToAdd) + other
267+
implicit final class StringAdd[A](private val self: A) extends AnyVal {
268+
def +(other: String) = String.valueOf(self) + other
269269
}
270270

271-
implicit final class RichException(val __throwableToEnrich: Throwable) extends AnyVal {
271+
implicit final class RichException(private val self: Throwable) extends AnyVal {
272272
import scala.compat.Platform.EOL
273-
@deprecated("Use Throwable#getStackTrace", "2.11.0") def getStackTraceString = __throwableToEnrich.getStackTrace().mkString("", EOL, EOL)
273+
@deprecated("Use Throwable#getStackTrace", "2.11.0") def getStackTraceString = self.getStackTrace().mkString("", EOL, EOL)
274274
}
275275

276276
implicit final class SeqCharSequence(val __sequenceOfChars: scala.collection.IndexedSeq[Char]) extends CharSequence {

src/library/scala/concurrent/duration/package.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ package object duration {
4040
implicit def pairLongToDuration(p: (Long, TimeUnit)): FiniteDuration = Duration(p._1, p._2)
4141
implicit def durationToPair(d: Duration): (Long, TimeUnit) = (d.length, d.unit)
4242

43-
implicit final class DurationInt(val n: Int) extends AnyVal with DurationConversions {
43+
implicit final class DurationInt(private val n: Int) extends AnyVal with DurationConversions {
4444
override protected def durationIn(unit: TimeUnit): FiniteDuration = Duration(n.toLong, unit)
4545
}
4646

47-
implicit final class DurationLong(val n: Long) extends AnyVal with DurationConversions {
47+
implicit final class DurationLong(private val n: Long) extends AnyVal with DurationConversions {
4848
override protected def durationIn(unit: TimeUnit): FiniteDuration = Duration(n, unit)
4949
}
5050

51-
implicit final class DurationDouble(val d: Double) extends AnyVal with DurationConversions {
51+
implicit final class DurationDouble(private val d: Double) extends AnyVal with DurationConversions {
5252
override protected def durationIn(unit: TimeUnit): FiniteDuration =
5353
Duration(d, unit) match {
5454
case f: FiniteDuration => f
@@ -59,17 +59,17 @@ package object duration {
5959
/*
6060
* Avoid reflection based invocation by using non-duck type
6161
*/
62-
implicit final class IntMult(val i: Int) extends AnyVal {
62+
implicit final class IntMult(private val i: Int) extends AnyVal {
6363
def *(d: Duration) = d * i.toDouble
6464
def *(d: FiniteDuration) = d * i.toLong
6565
}
6666

67-
implicit final class LongMult(val i: Long) extends AnyVal {
67+
implicit final class LongMult(private val i: Long) extends AnyVal {
6868
def *(d: Duration) = d * i.toDouble
6969
def *(d: FiniteDuration) = d * i.toLong
7070
}
7171

72-
implicit final class DoubleMult(val f: Double) extends AnyVal {
72+
implicit final class DoubleMult(private val f: Double) extends AnyVal {
7373
def *(d: Duration) = d * f.toDouble
7474
}
7575
}

src/library/scala/util/Either.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ object Either {
216216
* r.merge: Seq[Int] // Vector(1)
217217
* }}}
218218
*/
219-
implicit class MergeableEither[A](val x: Either[A, A]) extends AnyVal {
219+
implicit class MergeableEither[A](private val x: Either[A, A]) extends AnyVal {
220220
def merge: A = x match {
221221
case Left(a) => a
222222
case Right(a) => a

test/files/neg/logImplicits.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ logImplicits.scala:7: applied implicit conversion from String("abc") to ?{def ma
77
logImplicits.scala:15: inferred view from String("abc") to Int = C.this.convert:(p: String("abc"))Int
88
math.max(122, x: Int)
99
^
10-
logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def ArrowAssoc[A](__leftOfArrow: A): ArrowAssoc[A]
10+
logImplicits.scala:19: applied implicit conversion from Int(1) to ?{def ->: ?} = implicit def ArrowAssoc[A](self: A): ArrowAssoc[A]
1111
def f = (1 -> 2) + "c"
1212
^
13-
logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{def +: ?} = implicit def StringAdd[A](__thingToAdd: A): StringAdd[A]
13+
logImplicits.scala:19: applied implicit conversion from (Int, Int) to ?{def +: ?} = implicit def StringAdd[A](self: A): StringAdd[A]
1414
def f = (1 -> 2) + "c"
1515
^
1616
logImplicits.scala:22: error: class Un needs to be abstract, since method unimplemented is not defined

test/files/presentation/callcc-interpreter.check

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ reload: CallccInterpreter.scala
33
askTypeCompletion at CallccInterpreter.scala(51,38)
44
================================================================================
55
[response] askCompletionAt (51,38)
6-
retrieved 63 members
6+
retrieved 59 members
77
abstract trait Term extends AnyRef
88
abstract trait Value extends AnyRef
99
case class Add extends callccInterpreter.Term with Product with Serializable
@@ -52,10 +52,6 @@ final def synchronized[T0](x$1: T0): T0
5252
final def wait(): Unit
5353
final def wait(x$1: Long): Unit
5454
final def wait(x$1: Long,x$2: Int): Unit
55-
private[this] val __leftOfArrow: callccInterpreter.type
56-
private[this] val __resultOfEnsuring: callccInterpreter.type
57-
private[this] val __stringToFormat: callccInterpreter.type
58-
private[this] val __thingToAdd: callccInterpreter.type
5955
private[this] val term0: callccInterpreter.App
6056
private[this] val term1: callccInterpreter.App
6157
private[this] val term2: callccInterpreter.Add

test/files/presentation/ide-bug-1000349.check

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ reload: CompletionOnEmptyArgMethod.scala
33
askTypeCompletion at CompletionOnEmptyArgMethod.scala(2,17)
44
================================================================================
55
[response] askCompletionAt (2,17)
6-
retrieved 36 members
6+
retrieved 32 members
77
def +(other: String): String
88
def ->[B](y: B): (Foo, B)
99
def ensuring(cond: Boolean): Foo
@@ -31,10 +31,6 @@ final def synchronized[T0](x$1: T0): T0
3131
final def wait(): Unit
3232
final def wait(x$1: Long): Unit
3333
final def wait(x$1: Long,x$2: Int): Unit
34-
private[this] val __leftOfArrow: Foo
35-
private[this] val __resultOfEnsuring: Foo
36-
private[this] val __stringToFormat: Foo
37-
private[this] val __thingToAdd: Foo
3834
protected[package lang] def clone(): Object
3935
protected[package lang] def finalize(): Unit
4036
================================================================================

test/files/presentation/ide-bug-1000475.check

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ reload: Foo.scala
33
askTypeCompletion at Foo.scala(3,7)
44
================================================================================
55
[response] askCompletionAt (3,7)
6-
retrieved 35 members
6+
retrieved 31 members
77
[inaccessible] protected[package lang] def clone(): Object
88
[inaccessible] protected[package lang] def finalize(): Unit
99
def +(other: String): String
@@ -32,16 +32,12 @@ final def synchronized[T0](x$1: T0): T0
3232
final def wait(): Unit
3333
final def wait(x$1: Long): Unit
3434
final def wait(x$1: Long,x$2: Int): Unit
35-
private[this] val __leftOfArrow: Object
36-
private[this] val __resultOfEnsuring: Object
37-
private[this] val __stringToFormat: Object
38-
private[this] val __thingToAdd: Object
3935
================================================================================
4036

4137
askTypeCompletion at Foo.scala(6,10)
4238
================================================================================
4339
[response] askCompletionAt (6,10)
44-
retrieved 35 members
40+
retrieved 31 members
4541
[inaccessible] protected[package lang] def clone(): Object
4642
[inaccessible] protected[package lang] def finalize(): Unit
4743
def +(other: String): String
@@ -70,16 +66,12 @@ final def synchronized[T0](x$1: T0): T0
7066
final def wait(): Unit
7167
final def wait(x$1: Long): Unit
7268
final def wait(x$1: Long,x$2: Int): Unit
73-
private[this] val __leftOfArrow: Object
74-
private[this] val __resultOfEnsuring: Object
75-
private[this] val __stringToFormat: Object
76-
private[this] val __thingToAdd: Object
7769
================================================================================
7870

7971
askTypeCompletion at Foo.scala(7,7)
8072
================================================================================
8173
[response] askCompletionAt (7,7)
82-
retrieved 35 members
74+
retrieved 31 members
8375
[inaccessible] protected[package lang] def clone(): Object
8476
[inaccessible] protected[package lang] def finalize(): Unit
8577
def +(other: String): String
@@ -108,8 +100,4 @@ final def synchronized[T0](x$1: T0): T0
108100
final def wait(): Unit
109101
final def wait(x$1: Long): Unit
110102
final def wait(x$1: Long,x$2: Int): Unit
111-
private[this] val __leftOfArrow: Object
112-
private[this] val __resultOfEnsuring: Object
113-
private[this] val __stringToFormat: Object
114-
private[this] val __thingToAdd: Object
115103
================================================================================

test/files/presentation/ide-bug-1000531.check

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ reload: CrashOnLoad.scala
33
askTypeCompletion at CrashOnLoad.scala(6,12)
44
================================================================================
55
[response] askCompletionAt (6,12)
6-
retrieved 124 members
6+
retrieved 120 members
77
[inaccessible] protected[package lang] def clone(): Object
88
[inaccessible] protected[package lang] def finalize(): Unit
99
[inaccessible] protected[this] def reversed: List[B]
@@ -121,8 +121,4 @@ final def synchronized[T0](x$1: T0): T0
121121
final def wait(): Unit
122122
final def wait(x$1: Long): Unit
123123
final def wait(x$1: Long,x$2: Int): Unit
124-
private[this] val __leftOfArrow: java.util.Iterator[B]
125-
private[this] val __resultOfEnsuring: java.util.Iterator[B]
126-
private[this] val __stringToFormat: java.util.Iterator[B]
127-
private[this] val __thingToAdd: java.util.Iterator[B]
128124
================================================================================

0 commit comments

Comments
 (0)