Skip to content

Commit 7e17074

Browse files
committed
Allow arithmetic functions not mapping to Java equivalents
1 parent b1849f5 commit 7e17074

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,13 @@ open class KotlinUsesExtractor(
899899
return id
900900
}
901901

902+
// These are classes with Java equivalents, but whose methods don't all exist on those Java equivalents--
903+
// for example, the numeric classes define arithmetic functions (Int.plus, Long.or and so on) that lower to
904+
// primitive arithmetic on the JVM, but which we extract as calls to reflect the source syntax more closely.
905+
private val expectedMissingEquivalents = setOf(
906+
"kotlin.Boolean", "kotlin.Byte", "kotlin.Char", "kotlin.Double", "kotlin.Float", "kotlin.Int", "kotlin.Long", "kotlin.Number", "kotlin.Short"
907+
)
908+
902909
fun kotlinFunctionToJavaEquivalent(f: IrFunction, noReplace: Boolean) =
903910
if (noReplace)
904911
f
@@ -923,7 +930,10 @@ open class KotlinUsesExtractor(
923930
decl.valueParameters.size == f.valueParameters.size
924931
} ?:
925932
run {
926-
logger.warn("Couldn't find a Java equivalent function to ${parentClass.fqNameWhenAvailable}.${f.name} in ${javaClass.fqNameWhenAvailable}")
933+
val parentFqName = parentClass.fqNameWhenAvailable?.asString()
934+
if (!expectedMissingEquivalents.contains(parentFqName)) {
935+
logger.warn("Couldn't find a Java equivalent function to $parentFqName.${f.name} in ${javaClass.fqNameWhenAvailable}")
936+
}
927937
null
928938
}
929939
else

0 commit comments

Comments
 (0)