Questions tagged [scala-2.10]

Version 2.10 of the Scala language for the JVM. Use only if your question is specifically related to features of this version.

This tag is for the 2.10 version of the Scala language. The contents of this version are not yet decided, as it has not yet been released.

Use only if your question is specifically related to features of this version. Just because you are using this version, doesn't mean you need this tag. Use in addition to or instead of this tag.

See for more information.

590 questions
10
votes
1 answer

flatMap behavior changed in 2.10.0

I was converting some code from 2.9 to 2.10 and came across an unexpected compilation error. Here's the minimal form: In 2.9.2, this works fine: scala> List(1).flatMap(n => Set(1).collect { case w => w }) res0: List[Int] = List(1) In 2.10.0, we…
dhg
  • 52,383
  • 8
  • 123
  • 144
10
votes
3 answers

New behavior in Scala 2.10

Here are two REPL sessions (inspired by this question, although my question is different): Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0). Type in expressions to have them evaluated. Type :help for more…
Travis Brown
  • 138,631
  • 12
  • 375
  • 680
10
votes
1 answer

Which version of scala should I release my library to?

When I was releasing for scala 2.9.x, I simply had this line in my build.sbt: crossScalaVersions := Seq("2.9.0", "2.9.0-1", "2.9.1", "2.9.1-1", "2.9.2") But now, scala 2.10 is out, and I'm confused. My intuition was that I should have something…
Rogach
  • 26,050
  • 21
  • 93
  • 172
10
votes
1 answer

Checking for varargs type ascription in Scala macros

Suppose I have this macro: import language.experimental.macros import scala.reflect.macros.Context object FooExample { def foo[A](xs: A*): Int = macro foo_impl[A] def foo_impl[A](c: Context)(xs: c.Expr[A]*) = c.literal(xs.size) } This works as…
Travis Brown
  • 138,631
  • 12
  • 375
  • 680
10
votes
4 answers

Scala 2.10 TypeTag usage

I'm digging new scala reflection api and can't figure out why the following snippet doesn't work as expected. Given hierarchy (tried to simplify as much as I can): import scala.reflect.runtime.universe._ trait TF[A] { implicit def t: TypeTag[A] …
4e6
  • 10,696
  • 4
  • 52
  • 62
10
votes
1 answer

How can I get the actual object referred to by Scala 2.10 reflection?

Please consider this code: object ResponseType extends Enumeration { val Listing, Album = Value } I can get the Symbol referring to this object like so: import reflect.runtime.universe._ val s =…
Nikita Volkov
  • 42,792
  • 11
  • 94
  • 169
10
votes
1 answer

Searching inside scala 2.10 ASTs

What's the best way to recursively search for an element in scala 2.10 ASTs? The trees might be a result of power.trees(code) or mirror.mkToolBox().parseExpr(code) Edit. In 2.10.0-RC1 parseExpr has been renamed to parse. The concrete use-case that I…
9
votes
1 answer

Scala : Way to use a function directly into the println(...) using string interpolation

With Scala 2.10+ String Interpolation can be made. So I have this question. How can you do this: println(f"$foo(100,51)%1.0f" ) considering foo is a function like: def foo(x1:Int , x2:Int) : Double = { ... } From what I understand the way this…
billpcs
  • 633
  • 10
  • 17
9
votes
3 answers

No multipartconfig for servlet error from Jetty using scalatra

I am trying to unit test an upload call but I get this error for the following code: @MultipartConfig(maxFileSize = 3145728) class WebServlet extends ScalatraServlet with FileUploadSupport { override def isSizeConstraintException(e: Exception) = e…
James Black
  • 41,583
  • 10
  • 86
  • 166
9
votes
1 answer

Scala "update" immutable object best practices

With a mutable object I can write something like var user = DAO.getUser(id) user.name = "John" user.email ="john@doe.com" // logic on user If user is immutable then I need to clone\copy it on every change operation. I know a few ways to perform…
sh1ng
  • 2,808
  • 4
  • 24
  • 38
9
votes
1 answer

Is it possible to define a macro with variadic parameters, and get a type for each parameter?

The following is an obvious variadic function: def fun(xs: Any*) = ??? We can define a macro in a similar way: def funImpl(c: Context)(xs: c.Expr[Any]*) = ??? fun(1,"1",1.0) But in this case, all the arguments are typed as Any. In fact, the…
Rogach
  • 26,050
  • 21
  • 93
  • 172
9
votes
3 answers

Kill or timeout a Future in Scala 2.10

Hi, I'm using Scala 2.10 with the new futures library and I'm trying to write some code to test an infinite loop. I use a scala.concurrent.Future to run the code with the loop in a separate thread. I would then like to wait a little while to do…
Stephan
  • 191
  • 1
  • 8
9
votes
3 answers

__FUNC__ macro in Scala 2.10

In Scala 2.9.x, I wrote the func function which gives me back the name of the function where func() is executed like the FUNC C preprocessor macro. I understand that in Scala2.10 I should be able to write something more elegant than throwing an…
Eric Mariacher
  • 341
  • 1
  • 8
9
votes
1 answer

Replacing deprecated <:< Manifest type witness in Scala 2.10

Can someone point me at what I should be doing under scala 2.10 in place of this deprecated type witness on Manifest? reflect.ClassManifest.singleType(foo) <:< barManifest Honestly, my goal here is just to replace it with something that doesn't…
Josh Marcus
  • 1,749
  • 18
  • 30
9
votes
1 answer

How do I refer to enclosing "this" in a Scala macro?

The following macro, extracted from a larger example, is supposed to create a tree with nothing but a reference to this: def echoThisImpl(c:Context): c.Expr[Any] = { import c.universe._ val selfTree = This(c.enclosingClass.symbol) …