All Downloads are FREE. Search and download functionalities are using the official Maven repository.

wei-k.zeroapply_2.13.0-M4.0.2.2.source-code.EitherImpl.scala Maven / Gradle / Ivy

The newest version!
package zeroapply

import scala.reflect.macros.blackbox.Context

final class EitherImpl(override val c: Context) extends EitherBase{
  import c.universe._

  override protected def getValDef(name: TermName, left: Type, right: Type, body: Tree) =
    q"""val $name: _root_.scala.Either[$left, $right] = $body"""

  override protected def wrapRight(value: Tree) =
    q"_root_.scala.Right($value)"

  override protected def rightValue(value: Tree, left: Type, right: Type) = {
    if(scala.util.Properties.versionNumberString.startsWith("2.11")) {
      q"$value.asInstanceOf[_root_.scala.Right[$left, $right]].b"
    } else {
      q"$value.asInstanceOf[_root_.scala.Right[$left, $right]].value"
    }
  }

  override protected def asEither(value: Tree, left: Type, right: Tree) =
    q"$value.asInstanceOf[_root_.scala.Either[$left, $right]]"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy