java.lang.NoSuchMethodError thrown sometimes, fixed after deleting 'out' folder, then happens again


#1

I have a file with some extension functions, but when I call the following one specifically, a NoSuchMethodError is thrown:

java.lang.NoSuchMethodError: util.ExtensionsKt.toMonospaceWidth(I)D
private val widthCache by lazy {
    val metrics: FontMetrics = Toolkit.getToolkit().fontLoader.getFontMetrics(Font.font("myFontName"))
    Caffeine.newBuilder().initialCapacity(8).build<Int, Double> { metrics.computeStringWidth("." * it) + 20.0 }
}

fun Int.toMonospaceWidth(): Double = widthCache[this]!!

The weird about this is that it gets fixed if I delete the out folder, but after a few runs, the NoSuchMethodError is thrown again and I have to delete the out folder again, and it makes me lose time if I have to do it every time.

Environment

  • Kotlin 1.2.50
  • Java 1.8.0_171
  • IntelliJ IDEA 2018.1.5
  • Windows 10

Do any of you know which can be the cause or should I just file an Issue?