Potential issue with partial functions

19 views
Skip to first unread message

Alexandru Nedelcu

unread,
Jun 30, 2014, 4:08:22 AM6/30/14
to scala-mi...@googlegroups.com

Hi,

While playing around with miniboxing, I’ve encountered an issue. Take this piece of code:

import scala.concurrent.{ExecutionContext, Future}

trait Sample[@miniboxed T] {
  def process(elem: T): Future[Unit]

  def apply(elem: T)(implicit ec: ExecutionContext): Unit = {
    process(elem).onSuccess {
      case () => println("Done")
    }
  }
}

The above fails with a compilation error:

[error] .../Sample.scala:25: [ occured while creating miniboxed method apply_J in trait Sample_J ]
[error] type mismatch;
[error]  found   : x1.type (with underlying type Unit)
[error]  required: A1
[error]     process(elem).onSuccess {
[error]                             ^
[error] one error found

This seems to happen only for partial functions. If i change that onSuccess to onComplete, then it compiles fine.

Is this a bug? Should I file an issue in GitHub?

--
Alexandru Nedelcu
www.bionicspirit.com

PGP Public Key:
https://bionicspirit.com/key.aexpk

Vlad Ureche

unread,
Jun 30, 2014, 8:05:57 AM6/30/14
to Alexandru Nedelcu, scala-mi...@googlegroups.com
Nice catch Alexandru! Yes, it's a bug, a pretty big one.
Please file it on github.

Cheers,
Vlad


--
You received this message because you are subscribed to the Google Groups "Scala Miniboxing Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-miniboxi...@googlegroups.com.
To post to this group, send email to scala-mi...@googlegroups.com.
Visit this group at http://groups.google.com/group/scala-miniboxing.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-miniboxing/CAN9KCovYa3w0EEZ620THRGDFhTv%3Dhn75Zk1%3DXfyRGSZA9f3YtQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages