Skip to content

Commit e665d24

Browse files
committed
Disallow ')' in encoded names
The JVM spec does not prohibit this character so this appears to be an ASM bug, it worked fine in ASM 6.0 and crashes with 6.2 and 7.0. This fixes a crash in `dotty-semanticdb/test:compile`.
1 parent 6189ddc commit e665d24

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

library/src/scala/tasty/util/Chars.scala

+5-3
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ object Chars {
7373
}
7474

7575
/** Can `c` appear in an encoded name ?
76-
* This is true for all characters, except those prohibited in JVM signatures
77-
* (https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.9.1).
76+
* This is true for all characters, except:
77+
* - the characters prohibited in JVM signatures
78+
* (https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.9.1).
79+
* - ')' because it leads to crashes during code generation when using ASM 7.0.
7880
*/
7981
def isValidInEncodedName(c: Char): Boolean = (c: @switch) match {
80-
case '.' | ';' | '[' | '/' | '<' | '>' | ':' => false
82+
case '.' | ';' | '[' | '/' | '<' | '>' | ':' | ')' => false
8183
case _ => true
8284
}
8385

tests/run/special-names.scala

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class `/`
55
class `<`
66
class `>`
77
class `:`
8+
class `)`
89

910
object Test {
1011
def `.`(x: `.`) = x
@@ -14,6 +15,7 @@ object Test {
1415
def `<`(x: `<`) = x
1516
def `>`(x: `>`) = x
1617
def `:`(x: `:`) = x
18+
def `)`(x: `)`) = x
1719

1820
def main(args: Array[String]): Unit = {
1921
`.`(new `.`)
@@ -23,5 +25,6 @@ object Test {
2325
`<`(new `<`)
2426
`>`(new `>`)
2527
`:`(new `:`)
28+
`)`(new `)`)
2629
}
2730
}

0 commit comments

Comments
 (0)