Minor: simplify OperatorExpressionGenerator#invokeConversionFunction
This commit is contained in:
+19
-23
@@ -31,9 +31,6 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
import org.jetbrains.kotlin.psi2ir.findSingleFunction
|
import org.jetbrains.kotlin.psi2ir.findSingleFunction
|
||||||
import org.jetbrains.kotlin.psi2ir.intermediate.CallReceiver
|
|
||||||
import org.jetbrains.kotlin.psi2ir.intermediate.OnceExpressionValue
|
|
||||||
import org.jetbrains.kotlin.psi2ir.intermediate.SimpleCallReceiver
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
|
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
|
||||||
@@ -257,32 +254,31 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat
|
|||||||
this
|
this
|
||||||
|
|
||||||
else ->
|
else ->
|
||||||
SimpleCallReceiver(OnceExpressionValue(this), null)
|
invokeConversionFunction(
|
||||||
.invokeConversionFunction(
|
startOffset, endOffset,
|
||||||
startOffset, endOffset,
|
conversionFunction ?: throw AssertionError("No conversion function for $type ~> $targetType"),
|
||||||
conversionFunction ?: throw AssertionError("No conversion function for $type ~> $targetType")
|
this
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CallReceiver.invokeConversionFunction(
|
private fun invokeConversionFunction(
|
||||||
startOffset: Int,
|
startOffset: Int,
|
||||||
endOffset: Int,
|
endOffset: Int,
|
||||||
functionDescriptor: FunctionDescriptor
|
functionDescriptor: FunctionDescriptor,
|
||||||
|
receiver: IrExpression
|
||||||
): IrExpression =
|
): IrExpression =
|
||||||
call { dispatchReceiverValue, _ ->
|
IrCallImpl(
|
||||||
IrCallImpl(
|
startOffset,
|
||||||
startOffset,
|
endOffset,
|
||||||
endOffset,
|
functionDescriptor.returnType!!,
|
||||||
functionDescriptor.returnType!!,
|
context.symbolTable.referenceFunction(functionDescriptor.original),
|
||||||
context.symbolTable.referenceFunction(functionDescriptor.original),
|
functionDescriptor,
|
||||||
functionDescriptor,
|
typeArguments = null,
|
||||||
typeArguments = null,
|
origin = null, // TODO origin for widening conversions?
|
||||||
origin = null, // TODO origin for widening conversions?
|
superQualifierSymbol = null
|
||||||
superQualifierSymbol = null
|
).apply {
|
||||||
).apply {
|
dispatchReceiver = receiver
|
||||||
dispatchReceiver = dispatchReceiverValue!!.load()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KotlinType.findConversionFunctionTo(targetType: KotlinType): FunctionDescriptor? {
|
private fun KotlinType.findConversionFunctionTo(targetType: KotlinType): FunctionDescriptor? {
|
||||||
|
|||||||
Reference in New Issue
Block a user