@@ -33,51 +33,7 @@ object Trees {
33
33
/** Attachment key for trees with documentation strings attached */
34
34
val DocComment = new Attachment .Key [Comment ]
35
35
36
- /** Modifiers and annotations for definitions
37
- * @param flags The set flags
38
- * @param privateWithin If a private or protected has is followed by a
39
- * qualifier [q], the name q, "" as a typename otherwise.
40
- * @param annotations The annotations preceding the modifiers
41
- */
42
- case class Modifiers [- T >: Untyped ] (
43
- flags : FlagSet = EmptyFlags ,
44
- privateWithin : TypeName = tpnme.EMPTY ,
45
- annotations : List [Tree [T ]] = Nil ) extends Positioned with Cloneable {
46
-
47
- def is (fs : FlagSet ): Boolean = flags is fs
48
- def is (fc : FlagConjunction ): Boolean = flags is fc
49
-
50
- def | (fs : FlagSet ): Modifiers [T ] = withFlags(flags | fs)
51
- def & (fs : FlagSet ): Modifiers [T ] = withFlags(flags & fs)
52
- def &~ (fs : FlagSet ): Modifiers [T ] = withFlags(flags &~ fs)
53
-
54
- def toTypeFlags : Modifiers [T ] = withFlags(flags.toTypeFlags)
55
- def toTermFlags : Modifiers [T ] = withFlags(flags.toTermFlags)
56
-
57
- def withFlags (flags : FlagSet ) =
58
- if (this .flags == flags) this
59
- else copy(flags = flags)
60
-
61
- def withAddedAnnotation [U >: Untyped <: T ](annot : Tree [U ]): Modifiers [U ] =
62
- if (annotations.exists(_ eq annot)) this
63
- else withAnnotations(annotations :+ annot)
64
-
65
- def withAnnotations [U >: Untyped <: T ](annots : List [Tree [U ]]): Modifiers [U ] =
66
- if (annots eq annotations) this
67
- else copy(annotations = annots)
68
-
69
- def withPrivateWithin (pw : TypeName ) =
70
- if (pw.isEmpty) this
71
- else copy(privateWithin = pw)
72
-
73
- def hasFlags = flags != EmptyFlags
74
- def hasAnnotations = annotations.nonEmpty
75
- def hasPrivateWithin = privateWithin != tpnme.EMPTY
76
-
77
- def tokenPos : Seq [(Token , Position )] = ???
78
- }
79
-
80
- @ sharable private var nextId = 0 // for debugging
36
+ @ sharable private var nextId = 0 // for debugging
81
37
82
38
type LazyTree = AnyRef /* really: Tree | Lazy[Tree] */
83
39
type LazyTreeList = AnyRef /* really: List[Tree] | Lazy[List[Tree]] */
@@ -320,27 +276,27 @@ object Trees {
320
276
abstract class MemberDef [- T >: Untyped ] extends NameTree [T ] with DefTree [T ] {
321
277
type ThisTree [- T >: Untyped ] <: MemberDef [T ]
322
278
323
- private [this ] var myMods : Modifiers [ T ] = null
279
+ private [this ] var myMods : untpd. Modifiers = null
324
280
325
- private [dotc] def rawMods : Modifiers [ T ] =
326
- if (myMods == null ) genericEmptyModifiers else myMods
281
+ private [dotc] def rawMods : untpd. Modifiers =
282
+ if (myMods == null ) untpd. EmptyModifiers else myMods
327
283
328
284
def rawComment : Option [Comment ] = getAttachment(DocComment )
329
285
330
- def withMods (mods : Modifiers [ Untyped ] ): ThisTree [Untyped ] = {
286
+ def withMods (mods : untpd. Modifiers ): ThisTree [Untyped ] = {
331
287
val tree = if (myMods == null || (myMods == mods)) this else clone.asInstanceOf [MemberDef [Untyped ]]
332
288
tree.setMods(mods)
333
289
tree.asInstanceOf [ThisTree [Untyped ]]
334
290
}
335
291
336
- def withFlags (flags : FlagSet ): ThisTree [Untyped ] = withMods(Modifiers (flags))
292
+ def withFlags (flags : FlagSet ): ThisTree [Untyped ] = withMods(untpd. Modifiers (flags))
337
293
338
294
def setComment (comment : Option [Comment ]): ThisTree [Untyped ] = {
339
295
comment.map(putAttachment(DocComment , _))
340
296
asInstanceOf [ThisTree [Untyped ]]
341
297
}
342
298
343
- protected def setMods (mods : Modifiers [ T @ uncheckedVariance] ) = myMods = mods
299
+ protected def setMods (mods : untpd. Modifiers ) = myMods = mods
344
300
}
345
301
346
302
/** A ValDef or DefDef tree */
@@ -727,16 +683,14 @@ object Trees {
727
683
class EmptyValDef [T >: Untyped ] extends ValDef [T ](
728
684
nme.WILDCARD , genericEmptyTree[T ], genericEmptyTree[T ]) with WithoutTypeOrPos [T ] {
729
685
override def isEmpty : Boolean = true
730
- setMods(Modifiers [ T ] (PrivateLocal ))
686
+ setMods(untpd. Modifiers (PrivateLocal ))
731
687
}
732
688
733
689
@ sharable val theEmptyTree : Thicket [Type ] = Thicket (Nil )
734
690
@ sharable val theEmptyValDef = new EmptyValDef [Type ]
735
- @ sharable val theEmptyModifiers = new Modifiers ()
736
691
737
692
def genericEmptyValDef [T >: Untyped ]: ValDef [T ] = theEmptyValDef.asInstanceOf [ValDef [T ]]
738
693
def genericEmptyTree [T >: Untyped ]: Thicket [T ] = theEmptyTree.asInstanceOf [Thicket [T ]]
739
- def genericEmptyModifiers [T >: Untyped ]: Modifiers [T ] = theEmptyModifiers.asInstanceOf [Modifiers [T ]]
740
694
741
695
def flatten [T >: Untyped ](trees : List [Tree [T ]]): List [Tree [T ]] = {
742
696
var buf : ListBuffer [Tree [T ]] = null
@@ -795,7 +749,6 @@ object Trees {
795
749
796
750
abstract class Instance [T >: Untyped <: Type ] extends DotClass { inst =>
797
751
798
- type Modifiers = Trees .Modifiers [T ]
799
752
type Tree = Trees .Tree [T ]
800
753
type TypTree = Trees .TypTree [T ]
801
754
type TermTree = Trees .TermTree [T ]
@@ -853,14 +806,9 @@ object Trees {
853
806
854
807
@ sharable val EmptyTree : Thicket = genericEmptyTree
855
808
@ sharable val EmptyValDef : ValDef = genericEmptyValDef
856
- @ sharable val EmptyModifiers : Modifiers = genericEmptyModifiers
857
809
858
810
// ----- Auxiliary creation methods ------------------
859
811
860
- def Modifiers (flags : FlagSet = EmptyFlags ,
861
- privateWithin : TypeName = tpnme.EMPTY ,
862
- annotations : List [Tree ] = Nil ) = new Modifiers (flags, privateWithin, annotations)
863
-
864
812
def Thicket (trees : List [Tree ]): Thicket = new Thicket (trees)
865
813
def Thicket (): Thicket = EmptyTree
866
814
def Thicket (x1 : Tree , x2 : Tree ): Thicket = Thicket (x1 :: x2 :: Nil )
0 commit comments