diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-02-06 19:01:49 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-15 09:23:57 +0100 |
commit | 24780095d14938e60e28c710c47ed69629b7afc7 (patch) | |
tree | 7be93fa0110afd06c76a158a378d098d39908399 /src/reflect/scala | |
parent | fa8f4022754356859f3af1c4ffbac02ab3dc3e7c (diff) | |
download | scala-24780095d14938e60e28c710c47ed69629b7afc7.tar.gz scala-24780095d14938e60e28c710c47ed69629b7afc7.tar.bz2 scala-24780095d14938e60e28c710c47ed69629b7afc7.zip |
addresses pull request feedback
Diffstat (limited to 'src/reflect/scala')
-rw-r--r-- | src/reflect/scala/reflect/api/FlagSets.scala | 6 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Internals.scala | 2 | ||||
-rw-r--r-- | src/reflect/scala/reflect/macros/Enclosures.scala | 7 | ||||
-rw-r--r-- | src/reflect/scala/reflect/macros/Internals.scala | 5 | ||||
-rw-r--r-- | src/reflect/scala/reflect/macros/Typers.scala | 6 | ||||
-rw-r--r-- | src/reflect/scala/reflect/macros/Universe.scala | 2 |
6 files changed, 15 insertions, 13 deletions
diff --git a/src/reflect/scala/reflect/api/FlagSets.scala b/src/reflect/scala/reflect/api/FlagSets.scala index f36056cc3b..3d438e5b2f 100644 --- a/src/reflect/scala/reflect/api/FlagSets.scala +++ b/src/reflect/scala/reflect/api/FlagSets.scala @@ -176,9 +176,8 @@ trait FlagSets { self: Universe => val ENUM: FlagSet /** Flag indicating that tree represents a parameter of the primary constructor of some class - * or a synthetic member underlying thereof: + * or a synthetic member underlying thereof. E.g. here's how 'class C(val x: Int)' is represented: * - * 13:57 ~$ parse 'class C(val x: Int)' * [[syntax trees at end of parser]]// Scala source: tmposDU52 * class C extends scala.AnyRef { * <paramaccessor> val x: Int = _; @@ -202,9 +201,8 @@ trait FlagSets { self: Universe => val PARAMACCESSOR: FlagSet /** Flag indicating that tree represents a parameter of the primary constructor of some case class - * or a synthetic member underlying thereof: + * or a synthetic member underlying thereof. E.g. here's how 'case class C(val x: Int)' is represented: * - * 13:58 ~$ parse 'case class C(val x: Int)' * [[syntax trees at end of parser]]// Scala source: tmpnHkJ3y * case class C extends scala.Product with scala.Serializable { * <caseaccessor> <paramaccessor> val x: Int = _; diff --git a/src/reflect/scala/reflect/internal/Internals.scala b/src/reflect/scala/reflect/internal/Internals.scala index a152787ae1..ad0bcef48d 100644 --- a/src/reflect/scala/reflect/internal/Internals.scala +++ b/src/reflect/scala/reflect/internal/Internals.scala @@ -122,7 +122,7 @@ trait Internals extends api.Internals { def typeBounds(lo: Type, hi: Type): TypeBounds = self.TypeBounds(lo, hi) def boundedWildcardType(bounds: TypeBounds): BoundedWildcardType = self.BoundedWildcardType(bounds) - def subpatterns(tree: Tree): List[Tree] = tree.attachments.get[SubpatternsAttachment].get.patterns + def subpatterns(tree: Tree): Option[List[Tree]] = tree.attachments.get[SubpatternsAttachment].map(_.patterns.map(_.duplicate)) } lazy val treeBuild = new self.TreeGen { diff --git a/src/reflect/scala/reflect/macros/Enclosures.scala b/src/reflect/scala/reflect/macros/Enclosures.scala index 7c186139cf..69ede42cc7 100644 --- a/src/reflect/scala/reflect/macros/Enclosures.scala +++ b/src/reflect/scala/reflect/macros/Enclosures.scala @@ -20,7 +20,7 @@ import scala.language.existentials // SI-6541 * This is somewhat aligned with the overall evolution of macros during the 2.11 development cycle, where we played with * `c.introduceTopLevel` and `c.introduceMember`, but at the end of the day decided to reject them. * - * If you're relying on the now deprecated APIs, consider using the new [[c.enclosingOwner]] method that can be used to obtain + * If you're relying on the now deprecated APIs, consider using the new [[c.internal.enclosingOwner]] method that can be used to obtain * the names of enclosing definitions. Alternatively try reformulating your macros in terms of completely local expansion * and/or joining a discussion of a somewhat related potential language feature at [[https://groups.google.com/forum/#!topic/scala-debate/f4CLmYShX6Q]]. * We also welcome questions and suggestions on our mailing lists, where we would be happy to further discuss this matter. @@ -52,11 +52,6 @@ trait Enclosures { */ def enclosingPosition: Position - /** Symbol associated with the innermost enclosing lexical context. - * Walking the owner chain of this symbol will reveal information about more and more enclosing contexts. - */ - def enclosingOwner: Symbol - /** Tree that corresponds to the enclosing method, or EmptyTree if not applicable. * @see [[scala.reflect.macros.Enclosures]] */ diff --git a/src/reflect/scala/reflect/macros/Internals.scala b/src/reflect/scala/reflect/macros/Internals.scala index 415e70c36e..843644b7e3 100644 --- a/src/reflect/scala/reflect/macros/Internals.scala +++ b/src/reflect/scala/reflect/macros/Internals.scala @@ -14,6 +14,11 @@ trait Internals { /** @see [[scala.reflect.api.Internals]] */ trait ContextInternalApi extends universe.MacroInternalApi { + /** Symbol associated with the innermost enclosing lexical context. + * Walking the owner chain of this symbol will reveal information about more and more enclosing contexts. + */ + def enclosingOwner: Symbol + /** Functions that are available during [[transform]]. * @see [[transform]] */ diff --git a/src/reflect/scala/reflect/macros/Typers.scala b/src/reflect/scala/reflect/macros/Typers.scala index f1d8575774..d0dccb469d 100644 --- a/src/reflect/scala/reflect/macros/Typers.scala +++ b/src/reflect/scala/reflect/macros/Typers.scala @@ -27,7 +27,7 @@ trait Typers { /** Represents mode of operations of the typechecker underlying `c.typecheck` calls. * Is necessary since the shape of the typechecked tree alone is not enough to guess how it should be typechecked. - * Can be EXPRmode (typecheck as a term) or TYPEmode (typecheck as a type). + * Can be EXPRmode (typecheck as a term), TYPEmode (typecheck as a type) or PATTERNmode (typecheck as a pattern). */ // I'd very much like to make use of https://github.com/dsl-paradise/dsl-paradise here! type TypecheckMode @@ -41,6 +41,10 @@ trait Typers { */ val TYPEmode: TypecheckMode + /** Indicates that an argument to `c.typecheck` should be typechecked as a pattern. + */ + val PATTERNmode: TypecheckMode + /** @see `scala.reflect.macros.TypecheckException` */ type TypecheckException = scala.reflect.macros.TypecheckException diff --git a/src/reflect/scala/reflect/macros/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala index 23cd23cdb0..2dfb4ee0e2 100644 --- a/src/reflect/scala/reflect/macros/Universe.scala +++ b/src/reflect/scala/reflect/macros/Universe.scala @@ -138,7 +138,7 @@ abstract class Universe extends scala.reflect.api.Universe { /** Retrieves the untyped list of subpatterns attached to selector dummy of an UnApply node. * Useful in writing quasiquoting macros that do pattern matching. */ - def subpatterns(tree: Tree): List[Tree] + def subpatterns(tree: Tree): Option[List[Tree]] } /** @group Internal */ |