Merge pull request #1127 from retronym/topic/2.11-2.10-source-compat

using compat._ to plug source compatibility breakages
This commit is contained in:
Josh Suereth 2014-02-20 16:09:48 -05:00
commit c9f83dde47
5 changed files with 20 additions and 0 deletions

View File

@ -59,6 +59,9 @@ object InputWrapper
private[std] def wrapPrevious[T: c.WeakTypeTag](c: Context)(ts: c.Expr[Any], pos: c.Position): c.Expr[Option[T]] =
wrapImpl[Option[T],InputWrapper.type](c, InputWrapper, WrapPreviousName)(ts, pos)
// TODO 2.11 Remove this after dropping 2.10.x support.
private object HasCompat { val compat = ??? }; import HasCompat._
/** Wraps an arbitrary Tree in a call to the `<s>.<wrapName>` method of this module for later processing by an enclosing macro.
* The resulting Tree is the manually constructed version of:
*
@ -67,6 +70,7 @@ object InputWrapper
def wrapImpl[T: c.WeakTypeTag, S <: AnyRef with Singleton](c: Context, s: S, wrapName: String)(ts: c.Expr[Any], pos: c.Position)(implicit it: c.TypeTag[s.type]): c.Expr[T] =
{
import c.universe.{Apply=>ApplyTree,_}
import compat._
val util = new ContextUtil[c.type](c)
val iw = util.singleton(s)
val tpe = c.weakTypeOf[T]

View File

@ -281,9 +281,13 @@ object TaskMacro
private[this] def iTaskMacro[T: c.WeakTypeTag](c: Context)(t: c.Expr[T]): c.Expr[Task[T]] =
Instance.contImpl[T,Id](c, TaskInstance, TaskConvert, MixedBuilder)(Left(t), Instance.idTransform)
// TODO 2.11 Remove this after dropping 2.10.x support.
private object HasCompat { val compat = ??? }; import HasCompat._
private[this] def inputTaskDynMacro0[T: c.WeakTypeTag](c: Context)(t: c.Expr[Initialize[Task[T]]]): c.Expr[Initialize[InputTask[T]]] =
{
import c.universe.{Apply=>ApplyTree,_}
import compat._
val tag = implicitly[c.WeakTypeTag[T]]
val util = ContextUtil[c.type](c)

View File

@ -32,12 +32,16 @@ object ContextUtil {
def unexpectedTree[C <: Context](tree: C#Tree): Nothing = sys.error("Unexpected macro application tree (" + tree.getClass + "): " + tree)
}
// TODO 2.11 Remove this after dropping 2.10.x support.
private object HasCompat { val compat = ??? }; import HasCompat._
/** Utility methods for macros. Several methods assume that the context's universe is a full compiler (`scala.tools.nsc.Global`).
* This is not thread safe due to the underlying Context and related data structures not being thread safe.
* Use `ContextUtil[c.type](c)` to construct. */
final class ContextUtil[C <: Context](val ctx: C)
{
import ctx.universe.{Apply=>ApplyTree,_}
import compat._
val powerContext = ctx.asInstanceOf[reflect.macros.runtime.Context]
val global: powerContext.universe.type = powerContext.universe

View File

@ -9,11 +9,15 @@ package appmacro
/** A `TupleBuilder` that uses a KList as the tuple representation.*/
object KListBuilder extends TupleBuilder
{
// TODO 2.11 Remove this after dropping 2.10.x support.
private object HasCompat { val compat = ??? }; import HasCompat._
def make(c: Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type]
{
val ctx: c.type = c
val util = ContextUtil[c.type](c)
import c.universe.{Apply=>ApplyTree,_}
import compat._
import util._
val knilType = c.typeOf[KNil]

View File

@ -14,10 +14,14 @@ object TupleNBuilder extends TupleBuilder
final val MaxInputs = 11
final val TupleMethodName = "tuple"
// TODO 2.11 Remove this after dropping 2.10.x support.
private object HasCompat { val compat = ??? }; import HasCompat._
def make(c: Context)(mt: c.Type, inputs: Inputs[c.universe.type]): BuilderResult[c.type] = new BuilderResult[c.type]
{
val util = ContextUtil[c.type](c)
import c.universe.{Apply=>ApplyTree,_}
import compat._
import util._
val global: Global = c.universe.asInstanceOf[Global]