Edoardo Luppi
05/14/2025, 7:57 PMprivate fun replOrThrow(message: String): Char {
val repl = this.replacement // = private var replacement: Char? = '\uFFFD'
if (repl != null) {
return repl
}
throw MessageCharacterCodingException(message)
}
is translated to:
function replOrThrow_1($this, message) {
var repl = $this.qe_1;
var tmp = repl;
if (!((tmp == null ? null : new Char(tmp)) == null)) {
return repl;
}
throw MessageCharacterCodingException.xd(message);
}
Specifically the new Char(tmp)
thing. It looks like the char is not being treated as a simple number in this case (making it non-nullable doesn't help).Artem Kobzar
05/14/2025, 8:00 PMEdoardo Luppi
05/14/2025, 8:47 PMbroadway_lamb
05/15/2025, 12:01 AMChar
as a value class. Values of such classes are always boxed when they are put into a nullable storage.
This makes sense on other targets like JVM, Native and Wasm, but on JS we indeed could do better.Edoardo Luppi
05/15/2025, 8:35 AMEdoardo Luppi
05/15/2025, 8:40 AMChar
class is the only one for which you reserve a special treatment, at least by looking at the sources.
At least (I hope) the scope is limited.