@@ -14,10 +14,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
1414 // Note: the <: Type constraint looks necessary (and is needed to make the file compile in dotc).
1515 // But Scalac accepts the program happily without it. Need to find out why.
1616
17- def unsplice [T >: Untyped ](tree : Trees .Tree [T ]): Trees .Tree [T ] = tree.asInstanceOf [untpd.Tree ] match {
18- case untpd.TypedSplice (tree1) => tree1.asInstanceOf [Trees .Tree [T ]]
19- case _ => tree
20- }
17+ def unsplice (tree : Trees .Tree [T ]): Trees .Tree [T ] = tree
2118
2219 def isDeclarationOrTypeDef (tree : Tree ): Boolean = unsplice(tree) match {
2320 case DefDef (_, _, _, _, EmptyTree )
@@ -116,7 +113,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
116113 case _ => false
117114 }
118115
119- def isSuperSelection (tree : untpd. Tree ) = unsplice(tree) match {
116+ def isSuperSelection (tree : Tree ) = unsplice(tree) match {
120117 case Select (Super (_, _), _) => true
121118 case _ => false
122119 }
@@ -129,7 +126,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
129126 }
130127
131128 /** Is tree a variable pattern? */
132- def isVarPattern (pat : untpd. Tree ): Boolean = unsplice(pat) match {
129+ def isVarPattern (pat : Tree ): Boolean = unsplice(pat) match {
133130 case x : BackquotedIdent => false
134131 case x : Ident => x.name.isVariableName
135132 case _ => false
@@ -160,7 +157,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
160157 def isLeftAssoc (operator : Name ) = ! operator.isEmpty && (operator.toSimpleName.last != ':' )
161158
162159 /** can this type be a type pattern? */
163- def mayBeTypePat (tree : untpd. Tree ): Boolean = unsplice(tree) match {
160+ def mayBeTypePat (tree : Tree ): Boolean = unsplice(tree) match {
164161 case AndTypeTree (tpt1, tpt2) => mayBeTypePat(tpt1) || mayBeTypePat(tpt2)
165162 case OrTypeTree (tpt1, tpt2) => mayBeTypePat(tpt1) || mayBeTypePat(tpt2)
166163 case RefinedTypeTree (tpt, refinements) => mayBeTypePat(tpt) || refinements.exists(_.isInstanceOf [Bind ])
@@ -253,6 +250,13 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
253250 import TreeInfo ._
254251 import untpd ._
255252
253+ /** The underlying tree when stripping any TypedSplice or Parens nodes */
254+ override def unsplice (tree : Tree ): Tree = tree match {
255+ case TypedSplice (tree1) => tree1
256+ case Parens (tree1) => unsplice(tree1)
257+ case _ => tree
258+ }
259+
256260 /** True iff definition is a val or def with no right-hand-side, or it
257261 * is an abstract typoe declaration
258262 */
0 commit comments