@@ -206,7 +206,7 @@ object Trees {
206
206
def forwardTo = qual
207
207
}
208
208
209
- abstract class GenericApply [T ] extends ProxyTree [T ] with TermTree [T ] {
209
+ sealed abstract class GenericApply [T ] extends ProxyTree [T ] with TermTree [T ] {
210
210
type ThisTree [T ] <: GenericApply [T ]
211
211
val fun : Tree [T ]
212
212
val args : List [Tree [T ]]
@@ -485,7 +485,7 @@ object Trees {
485
485
}
486
486
487
487
/** A missing tree */
488
- abstract case class EmptyTree [T ]()
488
+ sealed abstract case class EmptyTree [T ]()
489
489
extends Tree [T ] with AlwaysEmpty [T ] {
490
490
type ThisTree [T ] = EmptyTree [T ]
491
491
}
@@ -496,7 +496,7 @@ object Trees {
496
496
def apply [T ]: EmptyTree [T ] = theEmptyTree.asInstanceOf
497
497
}
498
498
499
- abstract class EmptyValDef [T ] extends ValDef [T ](
499
+ sealed abstract class EmptyValDef [T ] extends ValDef [T ](
500
500
Modifiers [T ](Private ), nme.WILDCARD , EmptyTree [T ], EmptyTree [T ])(NoPosition ) with AlwaysEmpty [T ]
501
501
502
502
private object theEmptyValDef extends EmptyValDef [Nothing ]
@@ -506,7 +506,7 @@ object Trees {
506
506
}
507
507
508
508
/** A tree that can be shared without its position
509
- * polluting containing trees. Accumulators and tranformers
509
+ * polluting containing trees. Accumulators and transformers
510
510
* memoize results of shared subtrees
511
511
*/
512
512
final case class Shared [T ](shared : Tree [T ]) extends Tree [T ] {
@@ -518,20 +518,25 @@ object Trees {
518
518
519
519
// ----- Tree cases that exist in untyped form only ------------------
520
520
521
+ /** A marker trait for all Tree[Nothing] descendants. Useful for exhaustively pattern matching over Tree[U] */
522
+ sealed trait UntypedTreeMarker {
523
+ self : UntypedTree =>
524
+ }
525
+
521
526
/** A typed subtree of an untyped tree needs to be wrapped in a TypedSlice */
522
- final class TypedSplice (tree : TypedTree ) extends UntypedTree {
527
+ final class TypedSplice (tree : TypedTree ) extends UntypedTree with UntypedTreeMarker {
523
528
val pos = tree.pos
524
529
}
525
530
526
531
/** mods object name impl */
527
532
final case class ModuleDef (mods : Modifiers [Nothing ], name : TermName , impl : Template [Nothing ])(implicit cpos : Position )
528
- extends DefTree [Nothing ] {
533
+ extends DefTree [Nothing ] with UntypedTreeMarker {
529
534
val pos = cpos union impl.pos
530
535
}
531
536
532
537
/** (vparams) => body */
533
538
final case class Function (vparams : List [ValDef [Nothing ]], body : Tree [Nothing ])(implicit cpos : Position )
534
- extends TermTree [Nothing ] {
539
+ extends TermTree [Nothing ] with UntypedTreeMarker {
535
540
val pos = unionPos(cpos union body.pos, vparams)
536
541
}
537
542
@@ -800,6 +805,8 @@ object Trees {
800
805
tree1
801
806
},
802
807
tree, c, plugins)
808
+ case _ : UntypedTreeMarker =>
809
+ tree // TODO should this abort?
803
810
}
804
811
def transform (trees : List [Tree [T ]], c : C ): List [Tree [T ]] =
805
812
trees mapConserve (transform(_, c))
@@ -948,6 +955,8 @@ object Trees {
948
955
sharedMemo = sharedMemo.updated(tree, x1)
949
956
x1
950
957
}
958
+ case _ : UntypedTreeMarker =>
959
+ x
951
960
}
952
961
}
953
962
}
0 commit comments