I'm pretty sure this can be done using reflection API.
I'm using both Casbah and spray.json for creating JSON documents in a Scala project - one towards MongoDB, the other towards a REST API.
This can be confusing, at times. I would like to detect and disallow import
of the "wrong" library in a certain source file, making sure that future edits would never, ever mix the two approaches in the same code.
Probably there is no compile time mechanism for doing this (except for macros, not wanting to go so deep).
A runtime approach (e.g. placing within an object
body so it gets run right up front) would be fine. I.e. how to tell spray.json
namespace has been imported to this scope, in Scala?
Earlier questions: Prevent imports of unauthorized classes in Scala touches close, but is more about sandboxing (non-trusted code)