summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-01-21 04:25:44 -0800
committerEugene Burmako <xeno.by@gmail.com>2014-01-21 04:25:44 -0800
commita242101282ba986c4e336b759aaa08a32ca82a7b (patch)
tree6ac44b5195cda51f3a2e54e89c0aa250714797b1 /src/reflect/scala/reflect
parent26387cacaa8f78105419044fc33acc8fd8343662 (diff)
parent752f1eb63e931e04fd2818f32b6ca7e68e4298d2 (diff)
downloadscala-a242101282ba986c4e336b759aaa08a32ca82a7b.tar.gz
scala-a242101282ba986c4e336b759aaa08a32ca82a7b.tar.bz2
scala-a242101282ba986c4e336b759aaa08a32ca82a7b.zip
Merge pull request #3392 from xeno-by/topic/untypecheck
deprecates resetAllAttrs and resetLocalAttrs in favor of the new API
Diffstat (limited to 'src/reflect/scala/reflect')
-rw-r--r--src/reflect/scala/reflect/internal/Importers.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala4
-rw-r--r--src/reflect/scala/reflect/macros/Typers.scala26
-rw-r--r--src/reflect/scala/reflect/runtime/JavaUniverseForce.scala1
4 files changed, 27 insertions, 6 deletions
diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala
index 86038afaf1..483d0dd656 100644
--- a/src/reflect/scala/reflect/internal/Importers.scala
+++ b/src/reflect/scala/reflect/internal/Importers.scala
@@ -260,6 +260,8 @@ trait Importers extends api.Importers { to: SymbolTable =>
newExistentialType(tparams map importSymbol, importType(result))
case from.OverloadedType(pre, alts) =>
OverloadedType(importType(pre), alts map importSymbol)
+ case from.ImportType(qual) =>
+ ImportType(importTree(qual))
case from.AntiPolyType(pre, targs) =>
AntiPolyType(importType(pre), targs map importType)
case their: from.TypeVar =>
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 17a52c10e4..9ddaea4c62 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -2748,6 +2748,10 @@ trait Types
case _ => OverloadedType(pre, alternatives)
}
+ case class ImportType(expr: Tree) extends Type {
+ override def safeToString = "ImportType("+expr+")"
+ }
+
/** A class remembering a type instantiation for some a set of overloaded
* polymorphic symbols.
* Not used after phase `typer`.
diff --git a/src/reflect/scala/reflect/macros/Typers.scala b/src/reflect/scala/reflect/macros/Typers.scala
index 54336900f8..87de442921 100644
--- a/src/reflect/scala/reflect/macros/Typers.scala
+++ b/src/reflect/scala/reflect/macros/Typers.scala
@@ -69,18 +69,32 @@ trait Typers {
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.
- *
- * Note that this does not revert the tree to its pre-typer shape.
- * For more info, read up https://issues.scala-lang.org/browse/SI-5464.
+ * WARNING: Don't use this API, go for [[untypecheck]] instead.
*/
+ @deprecated("Use `c.untypecheck` instead", "2.11.0")
def resetAllAttrs(tree: Tree): Tree
/** Recursively resets locally defined symbols and types in a given tree.
- *
- * Note that this does not revert the tree to its pre-typer shape.
- * For more info, read up https://issues.scala-lang.org/browse/SI-5464.
+ * WARNING: Don't use this API, go for [[untypecheck]] instead.
*/
+ @deprecated("Use `c.untypecheck` instead", "2.11.0")
def resetLocalAttrs(tree: Tree): Tree
+
+ /** In the current implementation of Scala's reflection API, untyped trees (also known as parser trees or unattributed trees)
+ * are observationally different from typed trees (also known as typer trees, typechecked trees or attributed trees),
+ *
+ * Usually, if some compiler API takes a tree, then both untyped and typed trees will do. However in some cases,
+ * only untyped or only typed trees are appropriate. For example, [[eval]] only accepts untyped trees and one can only splice
+ * typed trees inside typed trees. Therefore in the current reflection API, there is a need in functions
+ * that go back and forth between untyped and typed trees. For this we have [[typecheck]] and `untypecheck`.
+ *
+ * Note that `untypecheck` is currently afflicted by https://issues.scala-lang.org/browse/SI-5464,
+ * which makes it sometimes corrupt trees so that they don't make sense anymore. Unfortunately, there's no workaround for that.
+ * We plan to fix this issue soon, but for now please keep it in mind.
+ *
+ * @see [[http://stackoverflow.com/questions/20936509/scala-macros-what-is-the-difference-between-typed-aka-typechecked-an-untyped]]
+ */
+ def untypecheck(tree: Tree): Tree
}
/** Indicates an error during one of the methods in [[scala.reflect.macros.Typers]].
diff --git a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
index 9224749864..b9b171c7ed 100644
--- a/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
+++ b/src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
@@ -170,6 +170,7 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
this.PolyType
this.ExistentialType
this.OverloadedType
+ this.ImportType
this.AntiPolyType
this.HasTypeMember
this.ArrayTypeRef