Class/Object

org.hammerlab.test.implicits

Conversions

Related Docs: object Conversions | package implicits

Permalink

macro class Conversions[From, To] extends Annotation with StaticAnnotation

Annotate a trait with To] this to generate a bunch of handy implicits for using one type (From) interchangeably with another (To) in tests:

\@Conversions[Int, String] trait IntToStringConversions { // Implicitly convert integers to strings by concatenating their string representations to themselves. implicit def intToString(n: Int): String = s"$n$n" }

The annotation will unroll a bunch of implicit functions for converting from e.g. Option[Int] to Option[String], Seq[Int] to Seq[String], etc. If an implicit => String is not give in the body of the trait, then one needs to be in scope where it is declared.

Downstream classes can then mix-in IntToStringConversions to have all such implicits in scope.

A macro is used so that multiple different Conversions traits can be mixed-in to a given concrete class without the implicit-names colliding (which would otherwise result in all but the last-to-be-mixed-in being hidden/shadowed); instead, the macro seeds all implicits' names with the types being converted between, avoiding the issue.

In order to use the Conversions annotation, macro paradise must be enabled.

Annotations
@compileTimeOnly( ... ) @compileTimeOnly( ... )
Linear Supertypes
StaticAnnotation, Annotation, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Conversions
  2. StaticAnnotation
  3. Annotation
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Conversions()

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. macro def macroTransform(annottees: Any*): Any

    Permalink
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  17. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from StaticAnnotation

Inherited from Annotation

Inherited from AnyRef

Inherited from Any

Ungrouped