Extract refactoring: Make an extracted function 'inline' if any of its type parameters are reified (#KT-23983)
This commit is contained in:
+18
-2
@@ -71,7 +71,12 @@ private fun buildSignature(config: ExtractionGeneratorConfiguration, renderer: D
|
||||
}
|
||||
return CallableBuilder(builderTarget).apply {
|
||||
val visibility = config.descriptor.visibility?.value ?: ""
|
||||
val extraModifiers = config.descriptor.modifiers.map { it.value }
|
||||
|
||||
fun TypeParameter.isReified() = originalDeclaration.hasModifier(KtTokens.REIFIED_KEYWORD)
|
||||
val shouldBeInline = config.descriptor.typeParameters.any { it.isReified() }
|
||||
|
||||
val extraModifiers = config.descriptor.modifiers.map { it.value } +
|
||||
listOfNotNull(if (shouldBeInline) KtTokens.INLINE_KEYWORD.value else null)
|
||||
val modifiers = if (visibility.isNotEmpty()) listOf(visibility) + extraModifiers else extraModifiers
|
||||
modifier(modifiers.joinToString(separator = " "))
|
||||
|
||||
@@ -79,7 +84,18 @@ private fun buildSignature(config: ExtractionGeneratorConfiguration, renderer: D
|
||||
config.descriptor.typeParameters.map {
|
||||
val typeParameter = it.originalDeclaration
|
||||
val bound = typeParameter.extendsBound
|
||||
typeParameter.name + (bound?.let { " : " + it.text } ?: "")
|
||||
|
||||
buildString {
|
||||
if (it.isReified()) {
|
||||
append(KtTokens.REIFIED_KEYWORD.value)
|
||||
append(' ')
|
||||
}
|
||||
append(typeParameter.name)
|
||||
if (bound != null) {
|
||||
append(" : ")
|
||||
append(bound.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user