Minor, add comment to synthetic accessor generation for super calls

Also fix "useless elvis" warning in SyntheticAccessorLowering.
This commit is contained in:
Alexander Udalov
2019-12-30 17:02:48 +01:00
parent b48d7f4ba7
commit c948459ed5
2 changed files with 11 additions and 12 deletions
@@ -33,7 +33,8 @@ private fun CallableMemberDescriptor.getJvmName() =
fun getAccessorNameSuffix(
descriptor: CallableMemberDescriptor, superCallDescriptor: ClassDescriptor?, accessorKind: AccessorKind
): String {
if (accessorKind == AccessorKind.JVM_DEFAULT_COMPATIBILITY) return descriptor.getJvmName() + "$" + AccessorKind.JVM_DEFAULT_COMPATIBILITY.suffix
if (accessorKind == AccessorKind.JVM_DEFAULT_COMPATIBILITY)
return descriptor.getJvmName() + "$" + AccessorKind.JVM_DEFAULT_COMPATIBILITY.suffix
val suffix = when (descriptor) {
is ConstructorDescriptor ->
@@ -45,5 +46,9 @@ fun getAccessorNameSuffix(
else ->
throw UnsupportedOperationException("Do not know how to create accessor for descriptor $descriptor")
}
return if (superCallDescriptor == null) suffix else "$suffix\$s${superCallDescriptor.name.asString().hashCode()}"
return if (superCallDescriptor == null) suffix else "$suffix\$s${superCallDescriptor.syntheticAccessorToSuperSuffix()}"
}
fun ClassDescriptor.syntheticAccessorToSuperSuffix(): String =
// TODO: change this to `fqNameUnsafe.asString().replace(".", "_")` as soon as we're ready to break compatibility with pre-KT-21178 code
name.asString().hashCode().toString()