Capitalize/decapitalize only ASCII characters across project
Use {de,}capitalizeAsciiOnly and to{Lower,Upper}CaseAsciiOnly where
possible, and stdlib's functions with Locale.US everywhere else.
Otherwise, if the default system locale is Turkish, the capital latin
letter "I" is transformed in toLowerCase to "ı" (see
https://github.com/JetBrains/kotlin/blob/66bc142f92085047a1ca64f9a291f0496e33dd98/libraries/stdlib/jvm/test/text/StringJVMTest.kt#L119),
which for example breaks the codegen for `intArrayOf` in
KT-25400/KT-43405.
Similarly, lower case latin letter "i" is transformed to "İ".
#KT-13631 Fixed
#KT-25400 Fixed
#KT-43405 Fixed
This commit is contained in:
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.js.backend.ast.*
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.SpecialFunction
|
||||
import org.jetbrains.kotlin.js.backend.ast.metadata.specialFunction
|
||||
import org.jetbrains.kotlin.js.dce.Context.Node
|
||||
import java.util.*
|
||||
|
||||
fun Context.isObjectDefineProperty(function: JsExpression) = isObjectFunction(function, "defineProperty")
|
||||
|
||||
@@ -46,7 +47,7 @@ fun Context.isObjectFunction(function: JsExpression, functionName: String): Bool
|
||||
fun Context.isKotlinFunction(function: JsExpression, name: String): Boolean {
|
||||
if (function !is JsNameRef || function.ident != name) return false
|
||||
val receiver = (function.qualifier as? JsNameRef)?.name ?: return false
|
||||
return receiver in nodes && receiver.ident.toLowerCase() == "kotlin"
|
||||
return receiver in nodes && receiver.ident.toLowerCase(Locale.US) == "kotlin"
|
||||
}
|
||||
|
||||
fun isSpecialFunction(expr: JsExpression, specialFunction: SpecialFunction): Boolean =
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.js.config
|
||||
|
||||
import java.util.*
|
||||
|
||||
enum class ErrorTolerancePolicy(val allowSyntaxErrors: Boolean, val allowSemanticErrors: Boolean) {
|
||||
NONE(false, false),
|
||||
SEMANTIC(false, true),
|
||||
@@ -16,7 +18,7 @@ enum class ErrorTolerancePolicy(val allowSyntaxErrors: Boolean, val allowSemanti
|
||||
val DEFAULT = NONE
|
||||
|
||||
fun resolvePolicy(key: String): ErrorTolerancePolicy {
|
||||
return when (key.toUpperCase()) {
|
||||
return when (key.toUpperCase(Locale.US)) {
|
||||
"NONE" -> NONE
|
||||
"SEMANTIC" -> SEMANTIC
|
||||
"SYNTAX", "ALL" -> ALL
|
||||
@@ -24,4 +26,4 @@ enum class ErrorTolerancePolicy(val allowSyntaxErrors: Boolean, val allowSemanti
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ object ArrayFIF : CompositeFIF() {
|
||||
}
|
||||
|
||||
private val PrimitiveType.lowerCaseName
|
||||
get() = typeName.asString().toLowerCase()
|
||||
get() = typeName.asString().toLowerCase(Locale.US)
|
||||
|
||||
fun getTag(descriptor: CallableDescriptor, config: JsConfig): String? {
|
||||
if (descriptor !is ConstructorDescriptor) return null
|
||||
|
||||
Reference in New Issue
Block a user