Skip to content

Commit 017f48e

Browse files
committed
String interpolation bug fix
This change fixes a bug in class StringContext.scala. Parts were not correctly added to the resulting string. This commit includes a test case which covers the example reported in the bug. Closes SI-5614.
1 parent d078b58 commit 017f48e

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/library/scala/StringContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ object StringContext {
144144
var cur = 0
145145
var idx = 0
146146
def output(ch: Char) = {
147-
bldr append str substring (start, cur)
147+
bldr append str.substring (start, cur)
148148
bldr append ch
149149
start = idx
150150
}

test/files/run/t5614.check

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3
2+
a
3+
b

test/files/run/t5614.flags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xexperimental

test/files/run/t5614.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Test extends App {
2+
val str = s"a\nb"
3+
println(str.length)
4+
println(str)
5+
}

0 commit comments

Comments
 (0)