Render annotations in suspend functions in single modifier list (KT-20185)
#KT-20185 Fixed
This commit is contained in:
@@ -309,22 +309,29 @@ internal class DescriptorRendererImpl(
|
||||
}
|
||||
val hasAnnotations = length != lengthBefore
|
||||
|
||||
val isSuspend = type.isSuspendFunctionType
|
||||
val isNullable = type.isMarkedNullable
|
||||
val receiverType = type.getReceiverTypeFromFunctionType()
|
||||
|
||||
val needParenthesis = isNullable || (hasAnnotations && receiverType != null)
|
||||
if (needParenthesis) {
|
||||
if (isSuspend) {
|
||||
insert(lengthBefore, '(')
|
||||
}
|
||||
else {
|
||||
if (hasAnnotations) {
|
||||
assert(last() == ' ')
|
||||
if (get(lastIndex - 1) != ')') {
|
||||
// last annotation rendered without parenthesis - need to add them otherwise parsing will be incorrect
|
||||
insert(lastIndex, "()")
|
||||
}
|
||||
}
|
||||
|
||||
if (needParenthesis && hasAnnotations) {
|
||||
assert(last() == ' ')
|
||||
if (get(lastIndex - 1) != ')') {
|
||||
// last annotation rendered without parenthesis - need to add them otherwise parsing will be incorrect
|
||||
insert(lastIndex, "()")
|
||||
append("(")
|
||||
}
|
||||
}
|
||||
|
||||
if (needParenthesis) append("(")
|
||||
|
||||
renderModifier(this, type.isSuspendFunctionType, "suspend")
|
||||
renderModifier(this, isSuspend, "suspend")
|
||||
|
||||
if (receiverType != null) {
|
||||
val surroundReceiver = shouldRenderAsPrettyFunctionType(receiverType) && !receiverType.isMarkedNullable ||
|
||||
|
||||
Reference in New Issue
Block a user