summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-08-02 06:10:59 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-08-02 06:10:59 -0700
commit937da62be2834a646a31dbfb01527a82672f111e (patch)
tree82b0b5efc904a6cf1355ee65631fa2e8c1a3c652 /src
parentcc1e50531bf7957bf05fff21d87a04ac550ccb53 (diff)
parentddcba109843d4f665a010f3dbbd28a6b99e6185a (diff)
downloadscala-937da62be2834a646a31dbfb01527a82672f111e.tar.gz
scala-937da62be2834a646a31dbfb01527a82672f111e.tar.bz2
scala-937da62be2834a646a31dbfb01527a82672f111e.zip
Merge pull request #1030 from scalamacros/ticket/5751
SI-5751 cleans up toolboxes for the release
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/reflect/makro/runtime/Typers.scala31
-rw-r--r--src/compiler/scala/tools/reflect/ToolBox.scala54
-rw-r--r--src/compiler/scala/tools/reflect/ToolBoxFactory.scala120
-rw-r--r--src/reflect/scala/reflect/api/Importers.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Importers.scala1
-rw-r--r--src/reflect/scala/reflect/makro/Typers.scala41
6 files changed, 137 insertions, 112 deletions
diff --git a/src/compiler/scala/reflect/makro/runtime/Typers.scala b/src/compiler/scala/reflect/makro/runtime/Typers.scala
index 18c1714d15..e43b0459ea 100644
--- a/src/compiler/scala/reflect/makro/runtime/Typers.scala
+++ b/src/compiler/scala/reflect/makro/runtime/Typers.scala
@@ -10,8 +10,9 @@ trait Typers {
def typeCheck(tree: Tree, pt: Type = universe.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree = {
macroLogVerbose("typechecking %s with expected type %s, implicit views = %s, macros = %s".format(tree, pt, !withImplicitViewsDisabled, !withMacrosDisabled))
- val wrapper1 = if (!withImplicitViewsDisabled) (callsiteTyper.context.withImplicitsEnabled[Tree] _) else (callsiteTyper.context.withImplicitsDisabled[Tree] _)
- val wrapper2 = if (!withMacrosDisabled) (callsiteTyper.context.withMacrosEnabled[Tree] _) else (callsiteTyper.context.withMacrosDisabled[Tree] _)
+ val context = callsiteTyper.context
+ val wrapper1 = if (!withImplicitViewsDisabled) (context.withImplicitsEnabled[Tree] _) else (context.withImplicitsDisabled[Tree] _)
+ val wrapper2 = if (!withMacrosDisabled) (context.withMacrosEnabled[Tree] _) else (context.withMacrosDisabled[Tree] _)
def wrapper (tree: => Tree) = wrapper1(wrapper2(tree))
// if you get a "silent mode is not available past typer" here
// don't rush to change the typecheck not to use the silent method when the silent parameter is false
@@ -31,29 +32,21 @@ trait Typers {
def inferImplicitValue(pt: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree = {
macroLogVerbose("inferring implicit value of type %s, macros = %s".format(pt, !withMacrosDisabled))
- import universe.analyzer.SearchResult
- val context = callsiteTyper.context
- val wrapper1 = if (!withMacrosDisabled) (context.withMacrosEnabled[SearchResult] _) else (context.withMacrosDisabled[SearchResult] _)
- def wrapper (inference: => SearchResult) = wrapper1(inference)
- wrapper(universe.analyzer.inferImplicit(universe.EmptyTree, pt, true, false, context, !silent, pos)) match {
- case failure if failure.tree.isEmpty =>
- macroLogVerbose("implicit search has failed. to find out the reason, turn on -Xlog-implicits")
- if (context.hasErrors) throw new universe.TypeError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
- universe.EmptyTree
- case success =>
- success.tree
- }
+ inferImplicit(universe.EmptyTree, pt, isView = false, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos)
+ }
+
+ def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree = {
+ macroLogVerbose("inferring implicit view from %s to %s for %s, macros = %s".format(from, to, tree, !withMacrosDisabled))
+ val viewTpe = universe.appliedType(universe.definitions.FunctionClass(1).asTypeConstructor, List(from, to))
+ inferImplicit(tree, viewTpe, isView = true, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos)
}
- def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true, pos: Position = enclosingPosition): Tree = {
- macroLogVerbose("inferring implicit view from %s to %s for %s, macros = %s, reportAmbiguous = %s".format(from, to, tree, !withMacrosDisabled, reportAmbiguous))
+ private def inferImplicit(tree: Tree, pt: Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: Position): Tree = {
import universe.analyzer.SearchResult
val context = callsiteTyper.context
val wrapper1 = if (!withMacrosDisabled) (context.withMacrosEnabled[SearchResult] _) else (context.withMacrosDisabled[SearchResult] _)
def wrapper (inference: => SearchResult) = wrapper1(inference)
- val fun1 = universe.definitions.FunctionClass(1)
- val viewTpe = universe.TypeRef(fun1.typeConstructor.prefix, fun1, List(from, to))
- wrapper(universe.analyzer.inferImplicit(tree, viewTpe, reportAmbiguous, true, context, !silent, pos)) match {
+ wrapper(universe.analyzer.inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context = context, saveAmbiguousDivergent = !silent, pos = pos)) match {
case failure if failure.tree.isEmpty =>
macroLogVerbose("implicit search has failed. to find out the reason, turn on -Xlog-implicits")
if (context.hasErrors) throw new universe.TypeError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
diff --git a/src/compiler/scala/tools/reflect/ToolBox.scala b/src/compiler/scala/tools/reflect/ToolBox.scala
index edd22c60f4..2505c1afb7 100644
--- a/src/compiler/scala/tools/reflect/ToolBox.scala
+++ b/src/compiler/scala/tools/reflect/ToolBox.scala
@@ -24,40 +24,46 @@ trait ToolBox[U <: Universe] {
/** Typechecks a tree using this ToolBox.
* This populates symbols and types of the tree and possibly transforms it to reflect certain desugarings.
*
- * If the tree has unresolved type variables (represented as instances of ``FreeTypeSymbol'' symbols),
- * then they might, might be partially or might not be specified in the ``freeTypes'' parameter.
+ * If the tree has unresolved type variables (represented as instances of `FreeTypeSymbol` symbols),
+ * then they all have to be resolved first using `Tree.substituteTypes`, or an error occurs.
*
- * If ``silent'' is false, ``TypeError'' will be thrown in case of a typecheck error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * If `silent` is false, `TypeError` will be thrown in case of a typecheck error.
+ * If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Ydebug.
*
* Typechecking can be steered with the following optional parameters:
- * ``withImplicitViewsDisabled'' recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
- * ``withMacrosDisabled'' recursively prohibits macro expansions and macro-based implicits, default value is false
+ * `withImplicitViewsDisabled` recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
+ * `withMacrosDisabled` recursively prohibits macro expansions and macro-based implicits, default value is false
*/
- def typeCheck(tree: u.Tree, pt: u.Type = u.WildcardType, freeTypes: Map[u.FreeTypeSymbol, u.Type] = Map[u.FreeTypeSymbol, u.Type](), silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree
+ def typeCheck(tree: u.Tree, pt: u.Type = u.WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree
-
- /** Infers an implicit value of the expected type ``pt'' in the macro callsite context.
+ /** Infers an implicit value of the expected type `pt` in top-level context.
+ * Optional `pos` parameter provides a position that will be associated with the implicit search.
+ *
+ * As mentioned in https://groups.google.com/forum/#!topic/scala-internals/ta-vbUT6JE8
+ * this API won't take into account the lexical context of the callsite, because
+ * currently it's impossible to reify it.
*
- * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * If `silent` is false, `TypeError` will be thrown in case of an inference error.
+ * If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in ``typeCheck'', ``silent'' is true by default.
+ * Unlike in `typeCheck`, `silent` is true by default.
*/
- def inferImplicitValue(pt: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false): u.Tree
+ def inferImplicitValue(pt: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree
- /** Infers an implicit view from the provided tree ``tree'' from the type ``from'' to the type ``to'' in the macro callsite context.
+ /** Infers an implicit view from the provided tree `tree` from the type `from` to the type `to` in the toplevel context.
+ * Optional `pos` parameter provides a position that will be associated with the implicit search.
*
- * Otional parameter, ``reportAmbiguous`` controls whether ambiguous implicit errors should be reported.
- * If we search for a view simply to find out whether one type is coercible to another, it might be desirable to set this flag to ``false''.
+ * As mentioned in https://groups.google.com/forum/#!topic/scala-internals/ta-vbUT6JE8
+ * this API won't take into account the lexical context of the callsite, because
+ * currently it's impossible to reify it.
*
- * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * If `silent` is false, `TypeError` will be thrown in case of an inference error.
+ * If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in ``typeCheck'', ``silent'' is true by default.
+ * Unlike in `typeCheck`, `silent` is true by default.
*/
- def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true): u.Tree
+ def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree
/** Recursively resets symbols and types in a given tree.
*
@@ -78,14 +84,14 @@ trait ToolBox[U <: Universe] {
/** Compiles and runs a tree using this ToolBox.
*
- * If the tree has unresolved type variables (represented as instances of ``FreeTypeSymbol'' symbols),
- * then they all have to be specified in the ``freeTypes'' parameter or an error occurs.
+ * If the tree has unresolved type variables (represented as instances of `FreeTypeSymbol` symbols),
+ * then they all have to be resolved first using `Tree.substituteTypes`, or an error occurs.
*
* This spawns the compiler at the Namer phase, and pipelines the tree through that compiler.
- * Currently ``runExpr'' does not accept trees that already typechecked, because typechecking isn't idempotent.
+ * Currently `runExpr` does not accept trees that already typechecked, because typechecking isn't idempotent.
* For more info, take a look at https://issues.scala-lang.org/browse/SI-5464.
*/
- def runExpr(tree: u.Tree, freeTypes: Map[u.FreeTypeSymbol, u.Type] = Map[u.FreeTypeSymbol, u.Type]()): Any
+ def runExpr(tree: u.Tree): Any
}
/** Represents an error during toolboxing
diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
index 589c5c7eb0..6c48762200 100644
--- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
+++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
@@ -97,7 +97,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
(expr, freeTermNames)
}
- def typeCheckExpr(expr0: Tree, pt: Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): Tree = {
+ def transformDuringTyper(expr0: Tree, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean)(transform: (analyzer.Typer, Tree) => Tree): Tree = {
verifyExpr(expr0)
// need to wrap the expr, because otherwise you won't be able to typecheck macros against something that contains free vars
@@ -121,34 +121,56 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
currentTyper.context.setReportErrors() // need to manually set context mode, otherwise typer.silent will throw exceptions
reporter.reset()
- trace("typing (implicit views = %s, macros = %s): ".format(!withImplicitViewsDisabled, !withMacrosDisabled))(showAttributed(expr, true, true, settings.Yshowsymkinds.value))
- wrapper(currentTyper.silent(_.typed(expr, analyzer.EXPRmode, pt)) match {
- case analyzer.SilentResultValue(result) =>
- trace("success: ")(showAttributed(result, true, true, settings.Yshowsymkinds.value))
- var (dummies, unwrapped) = result match {
- case Block(dummies, unwrapped) => (dummies, unwrapped)
- case unwrapped => (Nil, unwrapped)
+ val expr1 = wrapper(transform(currentTyper, expr))
+ var (dummies1, unwrapped) = expr1 match {
+ case Block(dummies, unwrapped) => (dummies, unwrapped)
+ case unwrapped => (Nil, unwrapped)
+ }
+ var invertedIndex = freeTerms map (_.swap)
+ // todo. also fixup singleton types
+ unwrapped = new Transformer {
+ override def transform(tree: Tree): Tree =
+ tree match {
+ case Ident(name) if invertedIndex contains name =>
+ Ident(invertedIndex(name)) setType tree.tpe
+ case _ =>
+ super.transform(tree)
}
- var invertedIndex = freeTerms map (_.swap)
- // todo. also fixup singleton types
- unwrapped = new Transformer {
- override def transform(tree: Tree): Tree =
- tree match {
- case Ident(name) if invertedIndex contains name =>
- Ident(invertedIndex(name)) setType tree.tpe
- case _ =>
- super.transform(tree)
- }
- }.transform(unwrapped)
- new TreeTypeSubstituter(dummies map (_.symbol), dummies map (dummy => SingleType(NoPrefix, invertedIndex(dummy.symbol.name)))).traverse(unwrapped)
- unwrapped
- case error @ analyzer.SilentTypeError(_) =>
- trace("failed: ")(error.err.errMsg)
- if (!silent) throw ToolBoxError("reflective typecheck has failed: %s".format(error.err.errMsg))
- EmptyTree
- })
+ }.transform(unwrapped)
+ new TreeTypeSubstituter(dummies1 map (_.symbol), dummies1 map (dummy => SingleType(NoPrefix, invertedIndex(dummy.symbol.name)))).traverse(unwrapped)
+ unwrapped
}
+ def typeCheckExpr(expr: Tree, pt: Type, silent: Boolean, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): Tree =
+ transformDuringTyper(expr, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled)(
+ (currentTyper, expr) => {
+ trace("typing (implicit views = %s, macros = %s): ".format(!withImplicitViewsDisabled, !withMacrosDisabled))(showAttributed(expr, true, true, settings.Yshowsymkinds.value))
+ currentTyper.silent(_.typed(expr, analyzer.EXPRmode, pt)) match {
+ case analyzer.SilentResultValue(result) =>
+ trace("success: ")(showAttributed(result, true, true, settings.Yshowsymkinds.value))
+ result
+ case error @ analyzer.SilentTypeError(_) =>
+ trace("failed: ")(error.err.errMsg)
+ if (!silent) throw ToolBoxError("reflective typecheck has failed: %s".format(error.err.errMsg))
+ EmptyTree
+ }
+ })
+
+ def inferImplicit(tree: Tree, pt: Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: Position): Tree =
+ transformDuringTyper(tree, withImplicitViewsDisabled = false, withMacrosDisabled = withMacrosDisabled)(
+ (currentTyper, tree) => {
+ trace("inferring implicit %s (macros = %s): ".format(if (isView) "view" else "value", !withMacrosDisabled))(showAttributed(pt, true, true, settings.Yshowsymkinds.value))
+ val context = currentTyper.context
+ analyzer.inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context = context, saveAmbiguousDivergent = !silent, pos = pos) match {
+ case failure if failure.tree.isEmpty =>
+ trace("implicit search has failed. to find out the reason, turn on -Xlog-implicits: ")(failure.tree)
+ if (context.hasErrors) throw ToolBoxError("reflective implicit search has failed: %s".format(context.errBuffer.head.errMsg))
+ EmptyTree
+ case success =>
+ success.tree
+ }
+ })
+
def compileExpr(expr: Tree): (Object, java.lang.reflect.Method) = {
verifyExpr(expr)
@@ -254,7 +276,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
}
}
- def showAttributed(tree: Tree, printTypes: Boolean = true, printIds: Boolean = true, printKinds: Boolean = false): String = {
+ def showAttributed(artifact: Any, printTypes: Boolean = true, printIds: Boolean = true, printKinds: Boolean = false): String = {
val saved1 = settings.printtypes.value
val saved2 = settings.uniqid.value
val saved3 = settings.Yshowsymkinds.value
@@ -262,7 +284,7 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
settings.printtypes.value = printTypes
settings.uniqid.value = printIds
settings.Yshowsymkinds.value = printKinds
- tree.toString
+ artifact.toString
} finally {
settings.printtypes.value = saved1
settings.uniqid.value = saved2
@@ -312,29 +334,37 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
lazy val exporter = importer.reverse
lazy val classLoader = new AbstractFileClassLoader(virtualDirectory, mirror.classLoader)
- def typeCheck(tree: u.Tree, expectedType: u.Type, freeTypes: Map[u.FreeTypeSymbol, u.Type], silent: Boolean, withImplicitViewsDisabled: Boolean, withMacrosDisabled: Boolean): u.Tree = {
- if (compiler.settings.verbose.value) println("typing "+tree+", expectedType = "+expectedType+", freeTypes = "+freeTypes)
+ def typeCheck(tree: u.Tree, expectedType: u.Type, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): u.Tree = {
+ if (compiler.settings.verbose.value) println("importing "+tree+", expectedType = "+expectedType)
var ctree: compiler.Tree = importer.importTree(tree)
var cexpectedType: compiler.Type = importer.importType(expectedType)
- if (compiler.settings.verbose.value) println("substituting "+ctree+", expectedType = "+expectedType)
- val cfreeTypes: Map[compiler.FreeTypeSymbol, compiler.Type] = freeTypes map { case (k, v) => (importer.importSymbol(k).asInstanceOf[compiler.FreeTypeSymbol], importer.importType(v)) }
- ctree = ctree.substituteTypes(cfreeTypes.keys.toList, cfreeTypes.values.toList)
- cexpectedType = cexpectedType.substituteTypes(cfreeTypes.keys.toList, cfreeTypes.values.toList)
-
if (compiler.settings.verbose.value) println("typing "+ctree+", expectedType = "+expectedType)
val ttree: compiler.Tree = compiler.typeCheckExpr(ctree, cexpectedType, silent = silent, withImplicitViewsDisabled = withImplicitViewsDisabled, withMacrosDisabled = withMacrosDisabled)
val uttree = exporter.importTree(ttree)
uttree
}
- def inferImplicitValue(pt: u.Type, silent: Boolean, withMacrosDisabled: Boolean): u.Tree =
- // todo. implement this
- ???
+ def inferImplicitValue(pt: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree = {
+ inferImplicit(u.EmptyTree, pt, isView = false, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos)
+ }
+
+ def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: u.Position = u.NoPosition): u.Tree = {
+ val viewTpe = u.appliedType(u.definitions.FunctionClass(1).asTypeConstructor, List(from, to))
+ inferImplicit(tree, viewTpe, isView = true, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = pos)
+ }
- def inferImplicitView(tree: u.Tree, from: u.Type, to: u.Type, silent: Boolean, withMacrosDisabled: Boolean, reportAmbiguous: Boolean): u.Tree =
- // todo. implement this
- ???
+ private def inferImplicit(tree: u.Tree, pt: u.Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: u.Position): u.Tree = {
+ if (compiler.settings.verbose.value) println("importing "+pt, ", tree = "+tree+", pos = "+pos)
+ var ctree: compiler.Tree = importer.importTree(tree)
+ var cpt: compiler.Type = importer.importType(pt)
+ var cpos: compiler.Position = importer.importPosition(pos)
+
+ if (compiler.settings.verbose.value) println("inferring implicit %s of type %s, macros = %s".format(if (isView) "view" else "value", pt, !withMacrosDisabled))
+ val itree: compiler.Tree = compiler.inferImplicit(ctree, cpt, isView = isView, silent = silent, withMacrosDisabled = withMacrosDisabled, pos = cpos)
+ val uitree = exporter.importTree(itree)
+ uitree
+ }
def resetAllAttrs(tree: u.Tree): u.Tree = {
val ctree: compiler.Tree = importer.importTree(tree)
@@ -360,14 +390,10 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
utree
}
- def runExpr(tree: u.Tree, freeTypes: Map[u.FreeTypeSymbol, u.Type]): Any = {
- if (compiler.settings.verbose.value) println("running "+tree+", freeTypes = "+freeTypes)
+ def runExpr(tree: u.Tree): Any = {
+ if (compiler.settings.verbose.value) println("importing "+tree)
var ctree: compiler.Tree = importer.importTree(tree)
- if (compiler.settings.verbose.value) println("substituting "+ctree)
- val cfreeTypes: Map[compiler.FreeTypeSymbol, compiler.Type] = freeTypes map { case (k, v) => (importer.importSymbol(k).asInstanceOf[compiler.FreeTypeSymbol], importer.importType(v)) }
- ctree = ctree.substituteTypes(cfreeTypes.keys.toList, cfreeTypes.values.toList)
-
if (compiler.settings.verbose.value) println("running "+ctree)
compiler.runExpr(ctree)
}
diff --git a/src/reflect/scala/reflect/api/Importers.scala b/src/reflect/scala/reflect/api/Importers.scala
index 69d6414f4f..de540a9605 100644
--- a/src/reflect/scala/reflect/api/Importers.scala
+++ b/src/reflect/scala/reflect/api/Importers.scala
@@ -17,5 +17,7 @@ trait Importers { self: Universe =>
def importType(tpe: from.Type): Type
def importTree(tree: from.Tree): Tree
+
+ def importPosition(pos: from.Position): Position
}
} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala
index 431d9819a5..00017e087a 100644
--- a/src/reflect/scala/reflect/internal/Importers.scala
+++ b/src/reflect/scala/reflect/internal/Importers.scala
@@ -14,6 +14,7 @@ trait Importers { self: SymbolTable =>
def importSymbol(sym: from.Symbol) = sym.asInstanceOf[self.Symbol]
def importType(tpe: from.Type) = tpe.asInstanceOf[self.Type]
def importTree(tree: from.Tree) = tree.asInstanceOf[self.Tree]
+ def importPosition(pos: from.Position) = pos.asInstanceOf[self.Position]
}
} else {
// todo. fix this loophole
diff --git a/src/reflect/scala/reflect/makro/Typers.scala b/src/reflect/scala/reflect/makro/Typers.scala
index 2610d7dd50..4176c184d0 100644
--- a/src/reflect/scala/reflect/makro/Typers.scala
+++ b/src/reflect/scala/reflect/makro/Typers.scala
@@ -10,8 +10,8 @@ trait Typers {
* Can be useful for interoperating with other macros and for imposing compiler-friendly limits on macro expansion.
*
* Is also priceless for emitting sane error messages for macros that are called by other macros on synthetic (i.e. position-less) trees.
- * In that dire case navigate the ``openMacros'' stack, and it will most likely contain at least one macro with a position-ful macro application.
- * See ``enclosingPosition'' for a default implementation of this logic.
+ * In that dire case navigate the `openMacros` stack, and it will most likely contain at least one macro with a position-ful macro application.
+ * See `enclosingPosition` for a default implementation of this logic.
*
* Unlike `enclosingMacros`, this is a def, which means that it gets recalculated on every invocation,
* so it might change depending on what is going on during macro expansion.
@@ -26,41 +26,38 @@ trait Typers {
*/
def openImplicits: List[(Type, Tree)]
- /** Typechecks the provided tree against the expected type ``pt'' in the macro callsite context.
+ /** Typechecks the provided tree against the expected type `pt` in the macro callsite context.
*
- * If ``silent'' is false, ``TypeError'' will be thrown in case of a typecheck error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * If `silent` is false, `TypeError` will be thrown in case of a typecheck error.
+ * If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Ymacro-debug-verbose.
- * Unlike in ``inferImplicitValue'' and ``inferImplicitView'', ``silent'' is false by default.
+ * Unlike in `inferImplicitValue` and `inferImplicitView`, `silent` is false by default.
*
* Typechecking can be steered with the following optional parameters:
- * ``withImplicitViewsDisabled'' recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
- * ``withMacrosDisabled'' recursively prohibits macro expansions and macro-based implicits, default value is false
+ * `withImplicitViewsDisabled` recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
+ * `withMacrosDisabled` recursively prohibits macro expansions and macro-based implicits, default value is false
*/
def typeCheck(tree: Tree, pt: Type = WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree
- /** Infers an implicit value of the expected type ``pt'' in the macro callsite context.
- * Optional ``pos'' parameter provides a position that will be associated with the implicit search.
+ /** Infers an implicit value of the expected type `pt` in the macro callsite context.
+ * Optional `pos` parameter provides a position that will be associated with the implicit search.
*
- * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * If `silent` is false, `TypeError` will be thrown in case of an inference error.
+ * If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in ``typeCheck'', ``silent'' is true by default.
+ * Unlike in `typeCheck`, `silent` is true by default.
*/
def inferImplicitValue(pt: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree
- /** Infers an implicit view from the provided tree ``tree'' from the type ``from'' to the type ``to'' in the macro callsite context.
+ /** Infers an implicit view from the provided tree `tree` of the type `from` to the type `to` in the macro callsite context.
+ * Optional `pos` parameter provides a position that will be associated with the implicit search.
*
- * Optional ``pos'' parameter provides a position that will be associated with the implicit search.
- * Another optional parameter, ``reportAmbiguous`` controls whether ambiguous implicit errors should be reported.
- * If we search for a view simply to find out whether one type is coercible to another, it might be desirable to set this flag to ``false''.
- *
- * If ``silent'' is false, ``TypeError'' will be thrown in case of an inference error.
- * If ``silent'' is true, the typecheck is silent and will return ``EmptyTree'' if an error occurs.
+ * If `silent` is false, `TypeError` will be thrown in case of an inference error.
+ * If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
- * Unlike in ``typeCheck'', ``silent'' is true by default.
+ * Unlike in `typeCheck`, `silent` is true by default.
*/
- def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, reportAmbiguous: Boolean = true, pos: Position = enclosingPosition): Tree
+ def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree
/** Recursively resets symbols and types in a given tree.
*