Back to Intellij Community

RedundantSamConstructor

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/RedundantSamConstructor.html

2025.3-rc-2322 B
Original Source

Reports SAM (Single Abstract Method) constructor usages which can be replaced with lambdas.

Example:

fun main() {
      foo(Runnable { println("Hi!") })
  }

  fun foo(other: Runnable) {}

After the quick-fix is applied:

fun main() {
      foo( { println("Hi!") })
  }

  fun foo(other: Runnable) {}