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:
+7
-5
@@ -16,16 +16,18 @@
|
||||
|
||||
package org.jetbrains.kotlin.descriptors.annotations
|
||||
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
||||
|
||||
enum class AnnotationUseSiteTarget(renderName: String? = null) {
|
||||
FIELD(),
|
||||
FILE(),
|
||||
PROPERTY(),
|
||||
FIELD,
|
||||
FILE,
|
||||
PROPERTY,
|
||||
PROPERTY_GETTER("get"),
|
||||
PROPERTY_SETTER("set"),
|
||||
RECEIVER(),
|
||||
RECEIVER,
|
||||
CONSTRUCTOR_PARAMETER("param"),
|
||||
SETTER_PARAMETER("setparam"),
|
||||
PROPERTY_DELEGATE_FIELD("delegate");
|
||||
|
||||
val renderName: String = renderName ?: name.toLowerCase()
|
||||
val renderName: String = renderName ?: name.toLowerCaseAsciiOnly()
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: NotFoundClasses) {
|
||||
@@ -35,7 +36,7 @@ class ReflectionTypes(module: ModuleDescriptor, private val notFoundClasses: Not
|
||||
|
||||
private class ClassLookup(val numberOfTypeParameters: Int) {
|
||||
operator fun getValue(types: ReflectionTypes, property: KProperty<*>): ClassDescriptor {
|
||||
return types.find(property.name.capitalize(), numberOfTypeParameters)
|
||||
return types.find(property.name.capitalizeAsciiOnly(), numberOfTypeParameters)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.declaresOrInheritsDefaultValu
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.ErrorUtils.UninferredParameterTypeConstructor
|
||||
import org.jetbrains.kotlin.types.TypeUtils.CANT_INFER_FUNCTION_PARAM_TYPE
|
||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
||||
import java.util.*
|
||||
|
||||
internal class DescriptorRendererImpl(
|
||||
@@ -494,7 +495,7 @@ internal class DescriptorRendererImpl(
|
||||
|
||||
private fun renderModality(modality: Modality, builder: StringBuilder, defaultModality: Modality) {
|
||||
if (!renderDefaultModality && modality == defaultModality) return
|
||||
renderModifier(builder, DescriptorRendererModifier.MODALITY in modifiers, modality.name.toLowerCase())
|
||||
renderModifier(builder, DescriptorRendererModifier.MODALITY in modifiers, modality.name.toLowerCaseAsciiOnly())
|
||||
}
|
||||
|
||||
private fun MemberDescriptor.implicitModalityWithoutExtensions(): Modality {
|
||||
@@ -538,7 +539,7 @@ internal class DescriptorRendererImpl(
|
||||
private fun renderMemberKind(callableMember: CallableMemberDescriptor, builder: StringBuilder) {
|
||||
if (DescriptorRendererModifier.MEMBER_KIND !in modifiers) return
|
||||
if (verbose && callableMember.kind != CallableMemberDescriptor.Kind.DECLARATION) {
|
||||
builder.append("/*").append(callableMember.kind.name.toLowerCase()).append("*/ ")
|
||||
builder.append("/*").append(callableMember.kind.name.toLowerCaseAsciiOnly()).append("*/ ")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user