Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ScalaCLPlugin] ClassCastException when using map with breakOut #45

Closed
ochafik opened this issue Sep 1, 2011 · 7 comments
Closed

[ScalaCLPlugin] ClassCastException when using map with breakOut #45

ochafik opened this issue Sep 1, 2011 · 7 comments
Assignees

Comments

@ochafik
Copy link
Member

ochafik commented Sep 1, 2011

What steps will reproduce the problem?

Run the following code:

object Test2 {
def main(args: Array[String]) {
val a: Set[Int] = List(1).map(_ + 1)(collection.breakOut)
println(a)
}
}

What is the expected output? What do you see instead?

Set(2), but instead we get:

Exception in thread "main" java.lang.ClassCastException: scala.collection.immutable.$colon$colon cannot be cast to scala.collection.immutable.Set
at test1.Test2$.main(tests.scala:10)
at test1.Test2.main(tests.scala)

What version of the product are you using? On what operating system?

0.2 SNAPSHOT from today.

Google Code Info:
Issue #: 43
Author: ismaelj
Created On: 2011-01-17T22:53:29.000Z
Closed On: 2011-01-18T13:49:41.000Z

@ghost ghost assigned ochafik Sep 1, 2011
@ochafik ochafik closed this as completed Sep 1, 2011
@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Oops, I forgot to add the title, but I can't edit the issue. Please add 'ClassCastException when using map with breakOut'

Google Code Info:
Author: ismaelj
Created On: 2011-01-17T22:54:08.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Excellent, thanks a lot Ismael ! (happy to have learnt a new toy in the process, breakOut looks very useful :-))

Btw, ScalaCL also works in the console (as hinted by the reporter of issue #40 and #41) :

SCALACL_VERBOSE=1 scala

val a: Set[Int] = List(1).map(_ + 1)(collection.breakOut)

Cheers

Google Code Info:
Author: olivier.chafik
Created On: 2011-01-17T23:03:00.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Useful to know (about console). :)

Google Code Info:
Author: ismaelj
Created On: 2011-01-17T23:12:12.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Fixed by revision #1580 in version 0.2.Beta6 (sbaz) and latest Maven 0.2-SNAPSHOT.

The fix only tries to stay away from exotic CanBuildFroms, but a clean fix will wait for the upcoming version 0.3 where operation streams are planned (a.map(f1).filter(f2).map(f3).toSet or ....map(f3)(collection.breakOut) will hence be treated the same way).

Thanks again for your report,

Cheers

Olivier

Google Code Info:
Author: olivier.chafik
Created On: 2011-01-18T13:49:32.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Google Code Info:
Author: olivier.chafik
Created On: 2011-01-18T13:49:41.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

Thanks!

Google Code Info:
Author: ismaelj
Created On: 2011-01-18T13:54:19.000Z

@ochafik
Copy link
Member Author

ochafik commented Sep 1, 2011

I tested the current snapshot in my project and all tests pass. :)

Google Code Info:
Author: ismaelj
Created On: 2011-01-18T19:48:06.000Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant