演算子の規則の 1 つと一致しているものの、operator キーワードがない関数を報告します。

operator 修飾子を追加すると、関数の利用者が Kotlin らしいコードを書けるようになります。

例:


  class Complex(val real: Double, val imaginary: Double) {
      fun plus(other: Complex) =
          Complex(real + other.real, imaginary + other.imaginary)
  }

  fun usage(a: Complex, b: Complex) {
      a.plus(b)
  }

クイックフィックスを使用すると、operator 修飾子キーワードが追加されます。


  class Complex(val real: Double, val imaginary: Double) {
      operator fun plus(other: Complex) =
          Complex(real + other.real, imaginary + other.imaginary)
  }

  fun usage(a: Complex, b: Complex) {
      a + b
  }