Kotlin Multiplatform and the Passive-Aggressive Compiler: A Love Story I Never Asked For
So I have this delicately horrific, platform-dependent gem in my KMP project:
inline infix fun Int.checkRight(previous: Int): Int {
return previous jvm {
mask.nextRight(previous)
} wasm {
if (pressedState) {
mask.nextRightClosest(this, previous)
} else {
mask.nextRight(previous)
}
} ios {
mask.nextRight(previous)
}
}
It's great. It saves me mental energy—something in short supply after working with Google, JetBrains, and the eternally confused lovechild they call Kotlin Multiplatform.
Used like this:
if (previous < selectionStart) selectionStart checkRight previous
else if (previous > selectionStart) selectionStart checkLeft previous
else previous
But the compiler, in its infinite passive-aggressive wisdom, blesses me with a bouquet of "Expected performance impact from inlining is insignificant" warnings like I just asked it to optimize crypto mining on a Tamagotchi.
w: .../TextInputMaskDsl.kt:237:13 [NOTHING_TO_INLINE] Expected performance impact from inlining is insignificant.
(Yes, there are more. Yes, I know. You don’t have to yell.)
So I suppress them:
@Suppress("NOTHING_TO_INLINE")
And Android Studio, ever the drama queen, throws a fit:
Redundant Suppression.
Right. So I’m wrong if I do, and wrong if I don’t. Good. Excellent. Very productive.
Remember when Knuth used to offer $10 for typos in his books, because he had this quaint thing called intellectual integrity? Now we've got armies of "best practice influencers" slapping "no guarantees" disclaimers on every repo like they're allergic to accountability.
All I want is for my KMP code not to gaslight me. That’s all.
