@@ -14,10 +14,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
14
14
// Note: the <: Type constraint looks necessary (and is needed to make the file compile in dotc).
15
15
// But Scalac accepts the program happily without it. Need to find out why.
16
16
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
21
18
22
19
def isDeclarationOrTypeDef (tree : Tree ): Boolean = unsplice(tree) match {
23
20
case DefDef (_, _, _, _, EmptyTree )
@@ -116,7 +113,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
116
113
case _ => false
117
114
}
118
115
119
- def isSuperSelection (tree : untpd. Tree ) = unsplice(tree) match {
116
+ def isSuperSelection (tree : Tree ) = unsplice(tree) match {
120
117
case Select (Super (_, _), _) => true
121
118
case _ => false
122
119
}
@@ -129,7 +126,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
129
126
}
130
127
131
128
/** Is tree a variable pattern? */
132
- def isVarPattern (pat : untpd. Tree ): Boolean = unsplice(pat) match {
129
+ def isVarPattern (pat : Tree ): Boolean = unsplice(pat) match {
133
130
case x : BackquotedIdent => false
134
131
case x : Ident => x.name.isVariableName
135
132
case _ => false
@@ -160,7 +157,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
160
157
def isLeftAssoc (operator : Name ) = ! operator.isEmpty && (operator.toSimpleName.last != ':' )
161
158
162
159
/** 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 {
164
161
case AndTypeTree (tpt1, tpt2) => mayBeTypePat(tpt1) || mayBeTypePat(tpt2)
165
162
case OrTypeTree (tpt1, tpt2) => mayBeTypePat(tpt1) || mayBeTypePat(tpt2)
166
163
case RefinedTypeTree (tpt, refinements) => mayBeTypePat(tpt) || refinements.exists(_.isInstanceOf [Bind ])
@@ -253,6 +250,13 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
253
250
import TreeInfo ._
254
251
import untpd ._
255
252
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
+
256
260
/** True iff definition is a val or def with no right-hand-side, or it
257
261
* is an abstract typoe declaration
258
262
*/
0 commit comments