E232: Use of Interpolator from Any

This warning is emitted when you use string interpolation syntax with a method from Any, such as toString.

Such a call is unlikely to be what you intended, and typically indicates a typo.


Example

val oops: String = toString" + " + "hello"

Error

-- [E232] Potential Issue Warning: example.scala:1:28 --------------------------
1 |val oops: String = toString" + " + "hello"
  |                            ^^^^^^^
  |                       Interpolator toString resolves to a method from Any
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  | String interpolation resolves to methods calls on StringContext,
  | which can target methods declared by Any such as toString.
  | This is unlikely to be what you intended.
   -----------------------------------------------------------------------------

Solution

If you truly mean to call such a method, use the full syntax to create a StringContext and call a method on it:

val ok = StringContext("hello").toString