@@ -21,15 +21,15 @@ trait Symbols { this: Context =>
21
21
22
22
// ---- Fundamental symbol creation methods ----------------------------------
23
23
24
- def newLazySymbol [N <: Name ](owner : Symbol , name : N , initFlags : FlagSet , completer : SymCompleter , coord : Coord = NoCoord ) =
24
+ final def newLazySymbol [N <: Name ](owner : Symbol , name : N , initFlags : FlagSet , completer : SymCompleter , coord : Coord = NoCoord ) =
25
25
new Symbol (coord, new LazySymDenotation (_, owner, name, initFlags, completer)) {
26
26
type ThisName = N
27
27
}
28
28
29
- def newLazyClassSymbol (owner : Symbol , name : TypeName , initFlags : FlagSet , completer : ClassCompleter , assocFile : AbstractFile = null , coord : Coord = NoCoord ) =
29
+ final def newLazyClassSymbol (owner : Symbol , name : TypeName , initFlags : FlagSet , completer : ClassCompleter , assocFile : AbstractFile = null , coord : Coord = NoCoord ) =
30
30
new ClassSymbol (coord, new LazyClassDenotation (_, owner, name, initFlags, completer, assocFile)(this ))
31
31
32
- def newLazyModuleSymbols (owner : Symbol ,
32
+ final def newLazyModuleSymbols (owner : Symbol ,
33
33
name : TermName ,
34
34
flags : FlagSet ,
35
35
completer : ClassCompleter ,
@@ -47,12 +47,12 @@ trait Symbols { this: Context =>
47
47
(module, modcls)
48
48
}
49
49
50
- def newSymbol [N <: Name ](owner : Symbol , name : N , flags : FlagSet , info : Type , privateWithin : Symbol = NoSymbol , coord : Coord = NoCoord ) =
50
+ final def newSymbol [N <: Name ](owner : Symbol , name : N , flags : FlagSet , info : Type , privateWithin : Symbol = NoSymbol , coord : Coord = NoCoord ) =
51
51
new Symbol (coord, CompleteSymDenotation (_, owner, name, flags, info, privateWithin)) {
52
52
type ThisName = N
53
53
}
54
54
55
- def newClassSymbol (
55
+ final def newClassSymbol (
56
56
owner : Symbol ,
57
57
name : TypeName ,
58
58
flags : FlagSet ,
@@ -66,7 +66,7 @@ trait Symbols { this: Context =>
66
66
new ClassSymbol (coord, new CompleteClassDenotation (
67
67
_, owner, name, flags, parents, privateWithin, optSelfType, decls, assocFile)(this ))
68
68
69
- def newModuleSymbols (
69
+ final def newModuleSymbols (
70
70
owner : Symbol ,
71
71
name : TermName ,
72
72
flags : FlagSet ,
@@ -89,7 +89,7 @@ trait Symbols { this: Context =>
89
89
(module, modcls)
90
90
}
91
91
92
- def newStubSymbol (owner : Symbol , name : Name , file : AbstractFile = null ): Symbol = {
92
+ final def newStubSymbol (owner : Symbol , name : Name , file : AbstractFile = null ): Symbol = {
93
93
def stub = new StubCompleter (ctx.condensed)
94
94
name match {
95
95
case name : TermName => ctx.newLazyModuleSymbols(owner, name, EmptyFlags , stub, file)._1
@@ -99,36 +99,36 @@ trait Symbols { this: Context =>
99
99
100
100
// ---- Derived symbol creation methods -------------------------------------
101
101
102
- def newLazyPackageSymbols (owner : Symbol , name : TermName , completer : ClassCompleter ) =
102
+ final def newLazyPackageSymbols (owner : Symbol , name : TermName , completer : ClassCompleter ) =
103
103
newLazyModuleSymbols(owner, name, PackageCreationFlags , completer)
104
104
105
- def newPackageSymbols (
105
+ final def newPackageSymbols (
106
106
owner : Symbol ,
107
107
name : TermName ,
108
108
decls : Scope = newScope) =
109
109
newModuleSymbols(
110
110
owner, name, PackageCreationFlags , PackageCreationFlags , Nil , NoSymbol , decls)
111
111
112
- def newLocalDummy (cls : Symbol , coord : Coord = NoCoord ) =
112
+ final def newLocalDummy (cls : Symbol , coord : Coord = NoCoord ) =
113
113
newSymbol(cls, nme.localDummyName(cls), EmptyFlags , NoType )
114
114
115
- def newImportSymbol (expr : TypedTree , coord : Coord = NoCoord ) =
115
+ final def newImportSymbol (expr : TypedTree , coord : Coord = NoCoord ) =
116
116
newSymbol(NoSymbol , nme.IMPORT , EmptyFlags , ImportType (expr), coord = coord)
117
117
118
- def newConstructor (cls : ClassSymbol , flags : FlagSet , paramNames : List [TermName ], paramTypes : List [Type ], privateWithin : Symbol = NoSymbol , coord : Coord = NoCoord ) =
118
+ final def newConstructor (cls : ClassSymbol , flags : FlagSet , paramNames : List [TermName ], paramTypes : List [Type ], privateWithin : Symbol = NoSymbol , coord : Coord = NoCoord ) =
119
119
newSymbol(cls, nme.CONSTRUCTOR , flags, MethodType (paramNames, paramTypes)(_ => cls.typeConstructor), privateWithin, coord)
120
120
121
- def newDefaultConstructor (cls : ClassSymbol ) =
121
+ final def newDefaultConstructor (cls : ClassSymbol ) =
122
122
newConstructor(cls, EmptyFlags , Nil , Nil )
123
123
124
- def newSelfSym (cls : ClassSymbol ) =
124
+ final def newSelfSym (cls : ClassSymbol ) =
125
125
ctx.newSymbol(cls, nme.THIS , SyntheticArtifact , cls.selfType)
126
126
127
127
/** Create new type parameters with given owner, names, and flags.
128
128
* @param boundsFn A function that, given type refs to the newly created
129
129
* parameters returns a list of their bounds.
130
130
*/
131
- def newTypeParams (
131
+ final def newTypeParams (
132
132
owner : Symbol ,
133
133
names : List [TypeName ],
134
134
flags : FlagSet ,
@@ -146,37 +146,37 @@ trait Symbols { this: Context =>
146
146
147
147
// ----- Locating predefined symbols ----------------------------------------
148
148
149
- def requiredPackage (path : PreName ): TermSymbol =
149
+ final def requiredPackage (path : PreName ): TermSymbol =
150
150
base.staticRef(path.toTermName).requiredSymbol(_.isPackage).asTerm
151
151
152
- def requiredClass (path : PreName ): ClassSymbol =
152
+ final def requiredClass (path : PreName ): ClassSymbol =
153
153
base.staticRef(path.toTypeName).requiredSymbol(_.isClass).asClass
154
154
155
- def requiredModule (path : PreName ): TermSymbol =
155
+ final def requiredModule (path : PreName ): TermSymbol =
156
156
base.staticRef(path.toTermName).requiredSymbol(_.isModule).asTerm
157
157
}
158
158
159
159
object Symbols {
160
160
161
161
/** A Symbol represents a Scala definition/declaration or a package.
162
162
*/
163
- class Symbol (val coord : Coord , denotf : Symbol => SymDenotation ) extends DotClass {
163
+ sealed class Symbol (val coord : Coord , denotf : Symbol => SymDenotation ) extends DotClass {
164
164
165
165
type ThisName <: Name
166
166
167
167
/** Is symbol different from NoSymbol? */
168
168
def exists = true
169
169
170
170
/** This symbol, if it exists, otherwise the result of evaluating `that` */
171
- def orElse (that : => Symbol ) = if (exists) this else that
171
+ final def orElse (that : => Symbol ) = if (exists) this else that
172
172
173
173
/** If this symbol satisfies predicate `p` this symbol, otherwise `NoSymbol` */
174
- def filter (p : Symbol => Boolean ): Symbol = if (p(this )) this else NoSymbol
174
+ final def filter (p : Symbol => Boolean ): Symbol = if (p(this )) this else NoSymbol
175
175
176
176
private [this ] var _id : Int = _
177
177
178
178
/** The unique id of this symbol */
179
- def id (implicit ctx : Context ) = {
179
+ final def id (implicit ctx : Context ) = {
180
180
if (_id == 0 ) _id = ctx.nextId
181
181
_id
182
182
}
@@ -215,31 +215,31 @@ object Symbols {
215
215
}
216
216
217
217
/** Is symbol a primitive value class? */
218
- def isPrimitiveValueClass (implicit ctx : Context ) = defn.ScalaValueClasses contains this
218
+ final def isPrimitiveValueClass (implicit ctx : Context ) = defn.ScalaValueClasses contains this
219
219
220
220
/** Is symbol a phantom class for which no runtime representation exists? */
221
- def isPhantomClass (implicit ctx : Context ) = defn.PhantomClasses contains this
221
+ final def isPhantomClass (implicit ctx : Context ) = defn.PhantomClasses contains this
222
222
223
223
/** The current name of this symbol */
224
224
final def name (implicit ctx : Context ): ThisName = denot.name.asInstanceOf [ThisName ]
225
225
226
- def show (implicit ctx : Context ): String = ctx.show(this )
227
- def showLocated (implicit ctx : Context ): String = ctx.showLocated(this )
228
- def showDcl (implicit ctx : Context ): String = ctx.showDcl(this )
229
- def showKind (implicit ctx : Context ): String = ctx.showKind(this )
230
- def showName (implicit ctx : Context ): String = ctx.showName(this )
231
- def showFullName (implicit ctx : Context ): String = ctx.showFullName(this )
226
+ final def show (implicit ctx : Context ): String = ctx.show(this )
227
+ final def showLocated (implicit ctx : Context ): String = ctx.showLocated(this )
228
+ final def showDcl (implicit ctx : Context ): String = ctx.showDcl(this )
229
+ final def showKind (implicit ctx : Context ): String = ctx.showKind(this )
230
+ final def showName (implicit ctx : Context ): String = ctx.showName(this )
231
+ final def showFullName (implicit ctx : Context ): String = ctx.showFullName(this )
232
232
233
233
}
234
234
235
235
type TermSymbol = Symbol { type ThisName = TermName }
236
236
type TypeSymbol = Symbol { type ThisName = TypeName }
237
237
238
- class ClassSymbol (coord : Coord , denotf : ClassSymbol => ClassDenotation ) extends Symbol (coord, s => denotf(s.asClass)) {
238
+ final class ClassSymbol (coord : Coord , denotf : ClassSymbol => ClassDenotation ) extends Symbol (coord, s => denotf(s.asClass)) {
239
239
240
240
type ThisName = TypeName
241
241
242
- final def classDenot (implicit ctx : Context ): ClassDenotation =
242
+ def classDenot (implicit ctx : Context ): ClassDenotation =
243
243
denot.asInstanceOf [ClassDenotation ]
244
244
245
245
private var superIdHint : Int = - 1
@@ -265,7 +265,7 @@ object Symbols {
265
265
}
266
266
}
267
267
268
- class ErrorSymbol (val underlying : Symbol , msg : => String )(implicit ctx : Context ) extends Symbol (NoCoord , sym => underlying.denot) {
268
+ final class ErrorSymbol (val underlying : Symbol , msg : => String )(implicit ctx : Context ) extends Symbol (NoCoord , sym => underlying.denot) {
269
269
type ThisName = underlying.ThisName
270
270
}
271
271
0 commit comments