Confuddled by EmptySet

20 views
Skip to first unread message

Paul Butcher

unread,
Feb 3, 2011, 9:19:26 AM2/3/11
to scala...@googlegroups.com
I'm trying to get ScalaTest up and running with 2.9.0-SNAPSHOT, and I'm seeing something that's confusing me.

ScalaTest is throwing a ClassCastException in this method:

> private[scalatest] def parseCompoundArgIntoSet(args: List[String], expectedDashArg: String): Set[String] =
> Set() ++ parseCompoundArgIntoList(args, expectedDashArg)


The exception is:

> java.lang.ClassCastException: scala.collection.immutable.Set$EmptySet$ cannot be cast to scala.collection.generic.Addable
> at org.scalatest.tools.Runner$.parseCompoundArgIntoSet(Runner.scala:1037)

It's nothing to do with what's returned by parseCompoundArgIntoList because I get exactly the same error if I change it to:

> private[scalatest] def parseCompoundArgIntoSet(args: List[String], expectedDashArg: String): Set[String] =
> Set() ++ List()

The weird thing is that I can't reproduce it in the REPL or in any small cut-down examples. For example:

> Welcome to Scala version 2.9.0.r24166-b20110202020121 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).

> Type in expressions to have them evaluated.
> Type :help for more information.
>
> scala> def foo(): Set[String] = Set() ++ List()
> foo: ()Set[String]
>
> scala> foo
> res0: Set[String] = Set()


So I'm stymied. It looks, from the error, as though the deprecated Set.EmptySet is being picked up, but I can't think why that would be the case? Does anyone have any suggestions for possible avenues of investigation?

--
paul.butcher->msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: pa...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher

Jason Zaugg

unread,
Feb 3, 2011, 9:47:14 AM2/3/11
to Paul Butcher, scala...@googlegroups.com
On Thu, Feb 3, 2011 at 3:19 PM, Paul Butcher <pa...@paulbutcher.com> wrote:
> I'm trying to get ScalaTest up and running with 2.9.0-SNAPSHOT, and I'm seeing something that's confusing me.
>
> ScalaTest is throwing a ClassCastException in this method:
>
>>   private[scalatest] def parseCompoundArgIntoSet(args: List[String], expectedDashArg: String): Set[String] =
>>       Set() ++ parseCompoundArgIntoList(args, expectedDashArg)
>
>
> The exception is:
>
>> java.lang.ClassCastException: scala.collection.immutable.Set$EmptySet$ cannot be cast to scala.collection.generic.Addable
>>       at org.scalatest.tools.Runner$.parseCompoundArgIntoSet(Runner.scala:1037)

Make sure all Scala libraries on the classpath were compiled with the
same version of scala.

-jason

Paul Butcher

unread,
Feb 3, 2011, 10:24:35 AM2/3/11
to Jason Zaugg, scala...@googlegroups.com
Thank you Jason - that's exactly it. ScalaTest includes a number of pre-compiled .jar files.

--

Paul Butcher

unread,
Feb 3, 2011, 6:15:37 PM2/3/11
to scala...@googlegroups.com, Jason Zaugg
Further to this - this explains the problem, but *should* it?

I know that 2.8 broke binary compatibility with 2.7, but I've been told that 2.9 should be binary compatible with 2.8 (although I can't find anything definitive on the subject)? Or have I got that wrong?

Jason Zaugg

unread,
Feb 4, 2011, 1:53:26 AM2/4/11
to Paul Butcher, scala...@googlegroups.com
On Fri, Feb 4, 2011 at 12:15 AM, Paul Butcher <pa...@paulbutcher.com> wrote:
> Further to this - this explains the problem, but *should* it?
>
> I know that 2.8 broke binary compatibility with 2.7, but I've been told that 2.9 should be binary compatible with 2.8 (although I can't find anything definitive on the subject)? Or have I got that wrong?


That is not a stated nor a realistic goal of 2.9. 2.9.{1, .. , n}
ought to be binary compatible with 2.9.0 however.

There may be a bytecode migration tool commercially available from
Scala Solutions [1]; but the simpler option is to use binaries
compiled for 2.9.x.

-jason

[1] http://www.scalasolutions.com/products/migrationmanager

Daniel Sobral

unread,
Feb 4, 2011, 3:56:11 PM2/4/11
to Jason Zaugg, Paul Butcher, scala...@googlegroups.com
And use SBT. SBT does a fine job at getting the right dependencies, for well-behaved projects.
--
Daniel C. Sobral

I travel to the future all the time.
Reply all
Reply to author
Forward
0 new messages