@@ -246,8 +246,11 @@ class ScalaTreeVisitor(
246246 // Strip them so we can parse the number correctly.
247247 val valueSource = rawSource.replaceAll(" [^0-9a-fA-FxXlLfFdDeE._+-]" , " " )
248248
249+ // Strip underscore digit separators; valueSource keeps them for printing.
250+ val parseSource = valueSource.replace(" _" , " " )
251+
249252 // Parse the number to determine its type and value
250- val (value : Any , javaType : JavaType .Primitive ) = valueSource match {
253+ val (value : Any , javaType : JavaType .Primitive ) = parseSource match {
251254 case s if s.startsWith(" 0x" ) || s.startsWith(" 0X" ) =>
252255 // Hexadecimal literal
253256 val hexStr = s.substring(2 )
@@ -257,11 +260,11 @@ class ScalaTreeVisitor(
257260 } else {
258261 (java.lang.Long .valueOf(longVal), JavaType .Primitive .Long )
259262 }
260- case s if s.endsWith(" L" ) || s.endsWith(" l" ) =>
263+ case s if s.endsWith(" L" ) || s.endsWith(" l" ) =>
261264 (java.lang.Long .valueOf(s.dropRight(1 )), JavaType .Primitive .Long )
262- case s if s.endsWith(" F" ) || s.endsWith(" f" ) =>
265+ case s if s.endsWith(" F" ) || s.endsWith(" f" ) =>
263266 (java.lang.Float .valueOf(s.dropRight(1 )), JavaType .Primitive .Float )
264- case s if s.endsWith(" D" ) || s.endsWith(" d" ) =>
267+ case s if s.endsWith(" D" ) || s.endsWith(" d" ) =>
265268 (java.lang.Double .valueOf(s.dropRight(1 )), JavaType .Primitive .Double )
266269 case s if s.contains(" ." ) || s.contains(" e" ) || s.contains(" E" ) =>
267270 (java.lang.Double .valueOf(s), JavaType .Primitive .Double )
0 commit comments