Skip to content

Commit eefd3b5

Browse files
committed
Disallow ')' in encoded names
The JVM spec does not prohibit this character but it leads to codegen crashes when using ASM 7.0, this has since been fixed in ASM master: https://gitlab.ow2.org/asm/asm/issues/317868 This fixes a crash in `dotty-semanticdb/test:compile`.
1 parent 6189ddc commit eefd3b5

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,15 @@ 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
80+
* (https://gitlab.ow2.org/asm/asm/issues/317868).
81+
* TODO: Remove this case when we upgrade ASM.
7882
*/
7983
def isValidInEncodedName(c: Char): Boolean = (c: @switch) match {
80-
case '.' | ';' | '[' | '/' | '<' | '>' | ':' => false
84+
case '.' | ';' | '[' | '/' | '<' | '>' | ':' | ')' => false
8185
case _ => true
8286
}
8387

tests/run/special-names.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class `/`
55
class `<`
66
class `>`
77
class `:`
8+
class `(`
9+
class `)`
810

911
object Test {
1012
def `.`(x: `.`) = x
@@ -14,6 +16,8 @@ object Test {
1416
def `<`(x: `<`) = x
1517
def `>`(x: `>`) = x
1618
def `:`(x: `:`) = x
19+
def `(`(x: `(`) = x
20+
def `)`(x: `)`) = x
1721

1822
def main(args: Array[String]): Unit = {
1923
`.`(new `.`)
@@ -23,5 +27,7 @@ object Test {
2327
`<`(new `<`)
2428
`>`(new `>`)
2529
`:`(new `:`)
30+
`(`(new `(`)
31+
`)`(new `)`)
2632
}
2733
}

0 commit comments

Comments
 (0)