Implicit resolution in descendants of associated types to avoid import tax

67 Views Asked by At
class JavaRxObservable
class MyObservable extends JavaRxObservable

object MyObservable {
  implicit class ObservablePimp(o: JavaRxObservable) {
    def flatMapPimp: JavaRxObservable = ... 
  }
}

def api: JavaRxObservable = new MyObservable

api.flatMapPimp // is this possible without import statement ?

Note that it is not possible to create a companion object to third party type JavaRxObservable. And since my api method must return JavaRxObservable type because of its combinatory nature (MyObservable#map would return JavaRxObservable), it is a major drawback in API design because you are forcing people to read documentation that they gotta import stuff to use your api. Not even declaration in package object helps if it is meant to be API used by third parties.

0

There are 0 best solutions below