summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-01-18 14:25:00 -0800
committerPaul Phillips <paulp@improving.org>2012-01-18 14:25:00 -0800
commitbb54827797f9c6584b048dde29e026603bb38cf2 (patch)
treec1efb5786dd4e2629f7cbba448fca220a356bf42
parent8f9b66200880087e0d8d1d95ae8be5de928825b5 (diff)
parent76caa37f22b70b126563df8a5eeab1b8bf693fc9 (diff)
downloadscala-bb54827797f9c6584b048dde29e026603bb38cf2.tar.gz
scala-bb54827797f9c6584b048dde29e026603bb38cf2.tar.bz2
scala-bb54827797f9c6584b048dde29e026603bb38cf2.zip
Merge remote-tracking branch 'dcsobral/interpolationFix'
-rw-r--r--src/library/scala/StringContext.scala4
-rw-r--r--test/files/run/interpolation.check6
-rw-r--r--test/files/run/interpolation.scala2
-rw-r--r--test/files/run/interpolationArgs.check2
-rw-r--r--test/files/run/interpolationArgs.flags1
-rw-r--r--test/files/run/interpolationArgs.scala5
6 files changed, 18 insertions, 2 deletions
diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala
index 1f0b4c766e..6116547aa2 100644
--- a/src/library/scala/StringContext.scala
+++ b/src/library/scala/StringContext.scala
@@ -43,7 +43,7 @@ case class StringContext(parts: String*) {
* that does not start a valid escape sequence.
*/
def s(args: Any*) = {
- checkLengths(args)
+ checkLengths(args: _*)
val pi = parts.iterator
val ai = args.iterator
val bldr = new java.lang.StringBuilder(treatEscapes(pi.next))
@@ -83,7 +83,7 @@ case class StringContext(parts: String*) {
* format specifier `%s` and adding a corresponding argument string `"%"`.
*/
def f(args: Any*) = {
- checkLengths(args)
+ checkLengths(args: _*)
val pi = parts.iterator
val ai = args.iterator
val bldr = new java.lang.StringBuilder
diff --git a/test/files/run/interpolation.check b/test/files/run/interpolation.check
index 4c34e4c8c8..09579a800a 100644
--- a/test/files/run/interpolation.check
+++ b/test/files/run/interpolation.check
@@ -2,14 +2,20 @@ Bob is 1 years old
Bob is 1 years old
Bob will be 2 years old
Bob will be 2 years old
+1+1 = 2
+1+1 = 2
Bob is 12 years old
Bob is 12 years old
Bob will be 13 years old
Bob will be 13 years old
+12+1 = 13
+12+1 = 13
Bob is 123 years old
Bob is 123 years old
Bob will be 124 years old
Bob will be 124 years old
+123+1 = 124
+123+1 = 124
Best price: 10.0
Best price: 10.00
10.0% discount included
diff --git a/test/files/run/interpolation.scala b/test/files/run/interpolation.scala
index 232a180bcd..a0a185eaab 100644
--- a/test/files/run/interpolation.scala
+++ b/test/files/run/interpolation.scala
@@ -5,6 +5,8 @@ object Test extends App {
println(f"Bob is $n%2d years old")
println(s"Bob will be ${n+1} years old")
println(f"Bob will be ${n+1}%2d years old")
+ println(s"$n+1 = ${n+1}")
+ println(f"$n%d+1 = ${n+1}%d")
}
def test2(f: Float) = {
diff --git a/test/files/run/interpolationArgs.check b/test/files/run/interpolationArgs.check
new file mode 100644
index 0000000000..155991e618
--- /dev/null
+++ b/test/files/run/interpolationArgs.check
@@ -0,0 +1,2 @@
+java.lang.IllegalArgumentException: wrong number of arguments for interpolated string
+java.lang.IllegalArgumentException: wrong number of arguments for interpolated string
diff --git a/test/files/run/interpolationArgs.flags b/test/files/run/interpolationArgs.flags
new file mode 100644
index 0000000000..e1b37447c9
--- /dev/null
+++ b/test/files/run/interpolationArgs.flags
@@ -0,0 +1 @@
+-Xexperimental \ No newline at end of file
diff --git a/test/files/run/interpolationArgs.scala b/test/files/run/interpolationArgs.scala
new file mode 100644
index 0000000000..eb13767907
--- /dev/null
+++ b/test/files/run/interpolationArgs.scala
@@ -0,0 +1,5 @@
+object Test extends App {
+ try { scala.StringContext("p1", "p2", "p3").s("e1") } catch { case ex => println(ex) }
+ try { scala.StringContext("p1").s("e1") } catch { case ex => println(ex) }
+}
+