@@ -55,17 +55,6 @@ case class StringContext(parts: String*) {
55
55
56
56
import StringContext ._
57
57
58
- /** Checks that the length of the given argument `args` is one less than the number
59
- * of `parts` supplied to the enclosing `StringContext`.
60
- * @param `args` The arguments to be checked.
61
- * @throws IllegalArgumentException if this is not the case.
62
- */
63
- def checkLengths (args : scala.collection.Seq [Any ]): Unit =
64
- if (parts.length != args.length + 1 )
65
- throw new IllegalArgumentException (" wrong number of arguments (" + args.length
66
- + " ) for interpolated string with " + parts.length + " parts" )
67
-
68
-
69
58
/** The simple string interpolator.
70
59
*
71
60
* It inserts its arguments between corresponding parts of the string context.
@@ -94,7 +83,7 @@ case class StringContext(parts: String*) {
94
83
* @note The Scala compiler may replace a call to this method with an equivalent, but more efficient,
95
84
* use of a StringBuilder.
96
85
*/
97
- def s (args : Any * ): String = standardInterpolator(processEscapes, args)
86
+ def s (args : Any * ): String = standardInterpolator(processEscapes, args, parts )
98
87
99
88
/** The raw string interpolator.
100
89
*
@@ -118,19 +107,7 @@ case class StringContext(parts: String*) {
118
107
* @note The Scala compiler may replace a call to this method with an equivalent, but more efficient,
119
108
* use of a StringBuilder.
120
109
*/
121
- def raw (args : Any * ): String = standardInterpolator(identity, args)
122
-
123
- def standardInterpolator (process : String => String , args : scala.collection.Seq [Any ]): String = {
124
- checkLengths(args)
125
- val pi = parts.iterator
126
- val ai = args.iterator
127
- val bldr = new JLSBuilder (process(pi.next()))
128
- while (ai.hasNext) {
129
- bldr append ai.next
130
- bldr append process(pi.next())
131
- }
132
- bldr.toString
133
- }
110
+ def raw (args : Any * ): String = standardInterpolator(identity, args, parts)
134
111
135
112
/** The formatted string interpolator.
136
113
*
@@ -244,4 +221,27 @@ object StringContext {
244
221
case i => replace(i)
245
222
}
246
223
}
224
+
225
+ private def standardInterpolator (process : String => String , args : scala.collection.Seq [Any ], parts : Seq [String ]): String = {
226
+ checkLengths(args, parts)
227
+ val pi = parts.iterator
228
+ val ai = args.iterator
229
+ val bldr = new JLSBuilder (process(pi.next()))
230
+ while (ai.hasNext) {
231
+ bldr append ai.next
232
+ bldr append process(pi.next())
233
+ }
234
+ bldr.toString
235
+ }
236
+
237
+ /** Checks that the length of the given argument `args` is one less than the number
238
+ * of `parts` supplied to the `StringContext`.
239
+ *
240
+ * @throws IllegalArgumentException if this is not the case.
241
+ */
242
+ private def checkLengths (args : scala.collection.Seq [Any ], parts : Seq [String ]): Unit =
243
+ if (parts.length != args.length + 1 )
244
+ throw new IllegalArgumentException (" wrong number of arguments (" + args.length
245
+ + " ) for interpolated string with " + parts.length + " parts" )
246
+
247
247
}
0 commit comments