diff options
author | Som Snytt <som.snytt@gmail.com> | 2014-08-02 14:24:54 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2014-08-12 08:41:14 -0700 |
commit | 2e3583b3644f3acd67933b54b9b61e6d60e9b6bb (patch) | |
tree | 44b86f84a504f109e3c524a98a92babc50c7af5e /test/junit | |
parent | 7a6947487dc8ea551ff7489b07cc30366b39d25e (diff) | |
download | scala-2e3583b3644f3acd67933b54b9b61e6d60e9b6bb.tar.gz scala-2e3583b3644f3acd67933b54b9b61e6d60e9b6bb.tar.bz2 scala-2e3583b3644f3acd67933b54b9b61e6d60e9b6bb.zip |
SI-8512 Infer a type for f"$args"
The f-interpolator gets a type param that better be Any to avoid
unfortunate widenings.
Hey, it worked!
Unfortunately, when `Any` is inferred, `-Xlint:infer-any` takes notice.
This is probably a greater problem for the f-interpolator than for
quasiquotes, which are a more specialized tool.
Diffstat (limited to 'test/junit')
-rw-r--r-- | test/junit/scala/StringContextTest.scala | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/junit/scala/StringContextTest.scala b/test/junit/scala/StringContextTest.scala index bb0e8c4252..608b82bd96 100644 --- a/test/junit/scala/StringContextTest.scala +++ b/test/junit/scala/StringContextTest.scala @@ -62,4 +62,17 @@ class StringContextTest { //assertEquals("????", s"????") assertEquals("!!!!", s"????") // OK to hijack core interpolator ids } + + @Test def fIf() = { + val res = f"${if (true) 2.5 else 2.5}%.2f" + assertEquals("2.50", res) + } + @Test def fIfNot() = { + val res = f"${if (false) 2.5 else 3.5}%.2f" + assertEquals("3.50", res) + } + @Test def fHeteroArgs() = { + val res = f"${3.14}%.2f rounds to ${3}%d" + assertEquals("3.14 rounds to 3", res) + } } |