0

I need to call from Java a Scala API that has a parameter with signature Option[Activity].

I want to pass Some(this), whose class is a derived class from Activity.

I have tried many things:

  • new Some<Activity>.apply(this)
  • Some.apply((Activity)this)
  • Option.apply((Activity)this)

but I get a compilation error like this:

actual argument Some<Activity> cannot be converted 
to Option<Class<? extends Activity>> by method invocation conversion

What is the right way of passing this?

Related questions:

1 Answer 1

1

Are you quite sure your method takes an Option[Activity]? Because that message suggests it's taking an Option[Class[_ <: Activity]]. Please post the Scala code and how you're calling it.

Sign up to request clarification or add additional context in comments.

1 Comment

A stupid error!. The exact Scala signature was: Option[Class[_ <: Activity]]. That explains everything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.