@@ -28,7 +28,7 @@ trait Names extends api.Names {
28
28
//
29
29
// Discussion: https://groups.google.com/forum/#!search/biased$20scala-internals/scala-internals/0cYB7SkJ-nM/47MLhsgw8jwJ
30
30
protected def synchronizeNames : Boolean = false
31
- private val nameLock : Object = new {}
31
+ private val nameLock : Object = new Object
32
32
33
33
/** Memory to store all names sequentially. */
34
34
var chrs : Array [Char ] = new Array [Char ](NAME_SIZE )
@@ -76,18 +76,19 @@ trait Names extends api.Names {
76
76
}
77
77
78
78
/** Create a term name from the characters in cs[offset..offset+len-1]. */
79
- def newTermName (cs : Array [Char ], offset : Int , len : Int ): TermName =
79
+ final def newTermName (cs : Array [Char ], offset : Int , len : Int ): TermName =
80
80
newTermName(cs, offset, len, cachedString = null )
81
81
82
- def newTermName (cs : Array [Char ]): TermName = newTermName(cs, 0 , cs.length)
83
- def newTypeName (cs : Array [Char ]): TypeName = newTypeName(cs, 0 , cs.length)
82
+ final def newTermName (cs : Array [Char ]): TermName = newTermName(cs, 0 , cs.length)
83
+
84
+ final def newTypeName (cs : Array [Char ]): TypeName = newTypeName(cs, 0 , cs.length)
84
85
85
86
/** Create a term name from the characters in cs[offset..offset+len-1].
86
87
* TODO - have a mode where name validation is performed at creation time
87
88
* (e.g. if a name has the string "$class" in it, then fail if that
88
89
* string is not at the very end.)
89
90
*/
90
- protected def newTermName (cs : Array [Char ], offset : Int , len : Int , cachedString : String ): TermName = {
91
+ final def newTermName (cs : Array [Char ], offset : Int , len : Int , cachedString : String ): TermName = {
91
92
def body = {
92
93
val h = hashValue(cs, offset, len) & HASH_MASK
93
94
var n = termHashtable(h)
@@ -108,33 +109,35 @@ trait Names extends api.Names {
108
109
if (synchronizeNames) nameLock.synchronized (body) else body
109
110
}
110
111
111
- protected def newTypeName (cs : Array [Char ], offset : Int , len : Int , cachedString : String ): TypeName =
112
+ final def newTypeName (cs : Array [Char ], offset : Int , len : Int , cachedString : String ): TypeName =
112
113
newTermName(cs, offset, len, cachedString).toTypeName
113
114
114
115
/** Create a term name from string. */
116
+ @ deprecatedOverriding(" To synchronize, use `override def synchronizeNames = true`" , " 2.11.0" ) // overriden in https://github.com/scala-ide/scala-ide/blob/master/org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaPresentationCompiler.scala
115
117
def newTermName (s : String ): TermName = newTermName(s.toCharArray(), 0 , s.length(), null )
116
118
117
119
/** Create a type name from string. */
120
+ @ deprecatedOverriding(" To synchronize, use `override def synchronizeNames = true`" , " 2.11.0" ) // overriden in https://github.com/scala-ide/scala-ide/blob/master/org.scala-ide.sdt.core/src/scala/tools/eclipse/ScalaPresentationCompiler.scala
118
121
def newTypeName (s : String ): TypeName = newTermName(s).toTypeName
119
122
120
123
/** Create a term name from the UTF8 encoded bytes in bs[offset..offset+len-1]. */
121
- def newTermName (bs : Array [Byte ], offset : Int , len : Int ): TermName = {
124
+ final def newTermName (bs : Array [Byte ], offset : Int , len : Int ): TermName = {
122
125
val chars = Codec .fromUTF8(bs, offset, len)
123
126
newTermName(chars, 0 , chars.length)
124
127
}
125
128
126
- def newTermNameCached (s : String ): TermName =
129
+ final def newTermNameCached (s : String ): TermName =
127
130
newTermName(s.toCharArray(), 0 , s.length(), cachedString = s)
128
131
129
- def newTypeNameCached (s : String ): TypeName =
132
+ final def newTypeNameCached (s : String ): TypeName =
130
133
newTypeName(s.toCharArray(), 0 , s.length(), cachedString = s)
131
134
132
135
/** Create a type name from the characters in cs[offset..offset+len-1]. */
133
- def newTypeName (cs : Array [Char ], offset : Int , len : Int ): TypeName =
136
+ final def newTypeName (cs : Array [Char ], offset : Int , len : Int ): TypeName =
134
137
newTermName(cs, offset, len, cachedString = null ).toTypeName
135
138
136
139
/** Create a type name from the UTF8 encoded bytes in bs[offset..offset+len-1]. */
137
- def newTypeName (bs : Array [Byte ], offset : Int , len : Int ): TypeName =
140
+ final def newTypeName (bs : Array [Byte ], offset : Int , len : Int ): TypeName =
138
141
newTermName(bs, offset, len).toTypeName
139
142
140
143
/**
0 commit comments