flavian
flavian

Reputation: 28511

Alias library implicits in a package object

Say I have:

import org.scalatest.ShouldMatchers._;

This brings a few implicit conversions into scope.

How can I alias them in a package object so that I can bring the implicits into scope with:

import code.ThePackageObject._;

Upvotes: 0

Views: 203

Answers (1)

Régis Jean-Gilles
Régis Jean-Gilles

Reputation: 32719

Apparently the ShouldMatchers object extends the ShouldMatchers trait (where the actual definition of the implicits are done). This is a common idiom that allows to simply mix the trait where you need it. So you can simply mix ShouldMatchers (the trait) in your package object:

package object ThePackageObject extends ShouldMatchers

Upvotes: 2

Related Questions