@@ -2235,6 +2235,9 @@ open class KotlinFileExtractor(
22352235 result
22362236 }
22372237
2238+ private fun isFunction (target : IrFunction , pkgName : String , classNameLogged : String , classNamePredicate : (String ) -> Boolean , vararg fNames : String , isNullable : Boolean? = false) =
2239+ fNames.any { isFunction(target, pkgName, classNameLogged, classNamePredicate, it, isNullable) }
2240+
22382241 private fun isFunction (target : IrFunction , pkgName : String , classNameLogged : String , classNamePredicate : (String ) -> Boolean , fName : String , isNullable : Boolean? = false): Boolean {
22392242 val verbose = false
22402243 fun verboseln (s : String ) { if (verbose) println (s) }
@@ -2291,7 +2294,7 @@ open class KotlinFileExtractor(
22912294 isFunction(target, " kotlin" , " Double" , fName)
22922295 }
22932296
2294- private fun isNumericFunction (target : IrFunction , fNames : List < String > ) = fNames.any { isNumericFunction(target, it) }
2297+ private fun isNumericFunction (target : IrFunction , vararg fNames : String ) = fNames.any { isNumericFunction(target, it) }
22952298
22962299 private fun isArrayType (typeName : String ) =
22972300 when (typeName) {
@@ -2428,10 +2431,18 @@ open class KotlinFileExtractor(
24282431 binopReceiver(id, c.dispatchReceiver, " Dispatch receiver" )
24292432 }
24302433
2434+ fun binopExt (id : Label <out DbExpr >) {
2435+ binopReceiver(id, c.extensionReceiver, " Extension receiver" )
2436+ }
2437+
24312438 fun unaryopDisp (id : Label <out DbExpr >) {
24322439 unaryopReceiver(id, c.dispatchReceiver, " Dispatch receiver" )
24332440 }
24342441
2442+ fun unaryopExt (id : Label <out DbExpr >) {
2443+ unaryopReceiver(id, c.extensionReceiver, " Extension receiver" )
2444+ }
2445+
24352446 val dr = c.dispatchReceiver
24362447 when {
24372448 isFunction(target, " kotlin" , " String" , " plus" , false ) -> {
@@ -2446,7 +2457,7 @@ open class KotlinFileExtractor(
24462457 extractRawMethodAccess(stringPlusFn, c, c.type, callable, parent, idx, enclosingStmt, listOf (c.extensionReceiver, c.getValueArgument(0 )), null , null )
24472458 }
24482459 }
2449- isNumericFunction(target, listOf ( " plus" , " minus" , " times" , " div" , " rem" , " and" , " or" , " xor" , " shl" , " shr" , " ushr" ) ) -> {
2460+ isNumericFunction(target, " plus" , " minus" , " times" , " div" , " rem" , " and" , " or" , " xor" , " shl" , " shr" , " ushr" ) -> {
24502461 val type = useType(c.type)
24512462 val id: Label <out DbExpr > = when (val targetName = target.name.asString()) {
24522463 " plus" -> {
@@ -2510,7 +2521,10 @@ open class KotlinFileExtractor(
25102521 }
25112522 }
25122523 tw.writeExprsKotlinType(id, type.kotlinResult.id)
2513- binopDisp(id)
2524+ if (isFunction(target, " kotlin" , " Byte or Short" , { it == " Byte" || it == " Short" }, " and" , " or" , " xor" ))
2525+ binopExt(id)
2526+ else
2527+ binopDisp(id)
25142528 }
25152529 // != gets desugared into not and ==. Here we resugar it.
25162530 c.origin == IrStatementOrigin .EXCLEQ && isFunction(target, " kotlin" , " Boolean" , " not" ) && c.valueArgumentsCount == 0 && dr != null && dr is IrCall && isBuiltinCallInternal(dr, " EQEQ" ) -> {
@@ -2541,7 +2555,7 @@ open class KotlinFileExtractor(
25412555 tw.writeExprsKotlinType(id, type.kotlinResult.id)
25422556 unaryopDisp(id)
25432557 }
2544- isNumericFunction(target, listOf ( " inv" , " unaryMinus" , " unaryPlus" ) ) -> {
2558+ isNumericFunction(target, " inv" , " unaryMinus" , " unaryPlus" ) -> {
25452559 val type = useType(c.type)
25462560 val id: Label <out DbExpr > = when (val targetName = target.name.asString()) {
25472561 " inv" -> {
@@ -2566,7 +2580,7 @@ open class KotlinFileExtractor(
25662580 }
25672581 tw.writeExprsKotlinType(id, type.kotlinResult.id)
25682582 if (isFunction(target, " kotlin" , " Byte or Short" , { it == " Byte" || it == " Short" }, " inv" ))
2569- unaryopReceiver (id, c.extensionReceiver, " Extension receiver " )
2583+ unaryopExt (id)
25702584 else
25712585 unaryopDisp(id)
25722586 }
0 commit comments