Simplify getIrFunctionByIrCall method in KFunctionState
Removed check of invoke symbols equality. Without this check it is possible to store init functions in KFunctionState
This commit is contained in:
committed by
TeamCityServer
parent
3d1d86e9cb
commit
a10d88924f
@@ -39,8 +39,6 @@ internal fun IrFunctionAccessExpression.getBody(): IrBody? = this.symbol.owner.b
|
|||||||
|
|
||||||
internal fun IrFunctionAccessExpression.getThisReceiver(): IrValueSymbol = this.symbol.owner.parentAsClass.thisReceiver!!.symbol
|
internal fun IrFunctionAccessExpression.getThisReceiver(): IrValueSymbol = this.symbol.owner.parentAsClass.thisReceiver!!.symbol
|
||||||
|
|
||||||
internal fun IrCall.isInvokeFun(): Boolean = this.origin == IrStatementOrigin.INVOKE || this.symbol.owner.name.asString() == "invoke"
|
|
||||||
|
|
||||||
internal fun State.toIrExpression(expression: IrExpression): IrExpression {
|
internal fun State.toIrExpression(expression: IrExpression): IrExpression {
|
||||||
val start = expression.startOffset
|
val start = expression.startOffset
|
||||||
val end = expression.endOffset
|
val end = expression.endOffset
|
||||||
|
|||||||
+1
-6
@@ -63,17 +63,12 @@ internal class KFunctionState(val irFunction: IrFunction, override val irClass:
|
|||||||
return _typeParameters!!
|
return _typeParameters!!
|
||||||
}
|
}
|
||||||
|
|
||||||
private val invokeSymbol = irClass.declarations
|
|
||||||
.single { it.nameForIrSerialization.asString() == "invoke" }
|
|
||||||
.cast<IrSimpleFunction>()
|
|
||||||
.getLastOverridden().symbol
|
|
||||||
|
|
||||||
fun getArity(): Int? {
|
fun getArity(): Int? {
|
||||||
return irClass.name.asString().removePrefix("Function").removePrefix("KFunction").toIntOrNull()
|
return irClass.name.asString().removePrefix("Function").removePrefix("KFunction").toIntOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getIrFunctionByIrCall(expression: IrCall): IrFunction? {
|
override fun getIrFunctionByIrCall(expression: IrCall): IrFunction? {
|
||||||
return if (invokeSymbol == expression.symbol) irFunction else null
|
return if (expression.symbol.owner.name.asString() == "invoke") irFunction else null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isLambda(): Boolean = irFunction.name.let { it == Name.special("<anonymous>") || it == Name.special("<no name provided>") }
|
private fun isLambda(): Boolean = irFunction.name.let { it == Name.special("<anonymous>") || it == Name.special("<no name provided>") }
|
||||||
|
|||||||
Reference in New Issue
Block a user