Skip to content

Commit 4bc3241

Browse files
committed
Add some extra details on the name encoding scheme
1 parent 159b3a8 commit 4bc3241

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/src/dotty/tools/dotc/util/NameTransformer.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ object NameTransformer {
4848
/** Replace operator symbols by corresponding expansion strings, and replace
4949
* characters that are not valid Java identifiers by "$u" followed by the
5050
* character's unicode expansion.
51+
* Note that no attempt is made to escape the use of '$' in `name`: blindly
52+
* escaping them might make it impossible to call some platform APIs. This
53+
* unfortunately means that `decode(encode(name))` might not be equal to
54+
* `name`, this is considered acceptable since '$' is a reserved character in
55+
* the Scala spec as well as the Java spec.
5156
*/
5257
def encode(name: SimpleName): SimpleName = {
5358
var buf: StringBuilder = null

0 commit comments

Comments
 (0)