Default arguments lowering should not touch inline functions.
This commit is contained in:
+5
-5
@@ -58,7 +58,7 @@ class DefaultArgumentStubGenerator internal constructor(val context: Context): D
|
|||||||
private fun lower(irFunction: IrFunction): List<IrFunction> {
|
private fun lower(irFunction: IrFunction): List<IrFunction> {
|
||||||
val functionDescriptor = irFunction.descriptor
|
val functionDescriptor = irFunction.descriptor
|
||||||
|
|
||||||
if (hasNotDefaultParameters(functionDescriptor))
|
if (!functionDescriptor.needsDefaultArgumentsLowering)
|
||||||
return irFunction.singletonList()
|
return irFunction.singletonList()
|
||||||
|
|
||||||
val bodies = functionDescriptor.valueParameters
|
val bodies = functionDescriptor.valueParameters
|
||||||
@@ -222,7 +222,7 @@ class DefaultParameterInjector internal constructor(val context: Context): BodyL
|
|||||||
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
|
override fun visitDelegatingConstructorCall(expression: IrDelegatingConstructorCall): IrExpression {
|
||||||
super.visitDelegatingConstructorCall(expression)
|
super.visitDelegatingConstructorCall(expression)
|
||||||
val descriptor = expression.descriptor
|
val descriptor = expression.descriptor
|
||||||
if (hasNotDefaultParameters(descriptor))
|
if (!descriptor.needsDefaultArgumentsLowering)
|
||||||
return expression
|
return expression
|
||||||
val argumentsCount = argumentCount(expression)
|
val argumentsCount = argumentCount(expression)
|
||||||
if (argumentsCount == descriptor.valueParameters.size)
|
if (argumentsCount == descriptor.valueParameters.size)
|
||||||
@@ -246,7 +246,7 @@ class DefaultParameterInjector internal constructor(val context: Context): BodyL
|
|||||||
super.visitCall(expression)
|
super.visitCall(expression)
|
||||||
val functionDescriptor = expression.descriptor as FunctionDescriptor
|
val functionDescriptor = expression.descriptor as FunctionDescriptor
|
||||||
|
|
||||||
if (hasNotDefaultParameters(functionDescriptor))
|
if (!functionDescriptor.needsDefaultArgumentsLowering)
|
||||||
return expression
|
return expression
|
||||||
|
|
||||||
val argumentsCount = argumentCount(expression)
|
val argumentsCount = argumentCount(expression)
|
||||||
@@ -326,8 +326,8 @@ class DefaultParameterInjector internal constructor(val context: Context): BodyL
|
|||||||
private fun log(msg: String) = context.log("DEFAULT-INJECTOR: $msg")
|
private fun log(msg: String) = context.log("DEFAULT-INJECTOR: $msg")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hasNotDefaultParameters(descriptor: CallableDescriptor) = descriptor.valueParameters.none { it.hasDefaultValue() }
|
private val CallableMemberDescriptor.needsDefaultArgumentsLowering
|
||||||
|
get() = valueParameters.any { it.hasDefaultValue() } && !(this is FunctionDescriptor && isInline)
|
||||||
|
|
||||||
private fun FunctionDescriptor.generateDefaultsDescription(context: Context): FunctionDescriptor {
|
private fun FunctionDescriptor.generateDefaultsDescription(context: Context): FunctionDescriptor {
|
||||||
return context.ir.defaultParameterDescriptorsCache.getOrPut(this) {
|
return context.ir.defaultParameterDescriptorsCache.getOrPut(this) {
|
||||||
|
|||||||
@@ -312,8 +312,10 @@ public inline fun String.subSequence(start: Int, end: Int): CharSequence = subSe
|
|||||||
* @param startIndex the start index (inclusive).
|
* @param startIndex the start index (inclusive).
|
||||||
* @param endIndex the end index (exclusive). If not specified, the length of the char sequence is used.
|
* @param endIndex the end index (exclusive). If not specified, the length of the char sequence is used.
|
||||||
*/
|
*/
|
||||||
|
// TODO: uncomment as soon as inlining works for stdlib.
|
||||||
|
@Fixme
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun CharSequence.substring(startIndex: Int, endIndex: Int = length): String = subSequence(startIndex, endIndex).toString()
|
public /*inline*/ fun CharSequence.substring(startIndex: Int, endIndex: Int = length): String = subSequence(startIndex, endIndex).toString()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a substring of chars at indices from the specified [range] of this char sequence.
|
* Returns a substring of chars at indices from the specified [range] of this char sequence.
|
||||||
|
|||||||
Reference in New Issue
Block a user