It is common practice to limit certain methods that must be performed against certain types. In fact, <:< is a type defined in scala.Predef as follows:
@implicitNotFound(msg = "Cannot prove that ${From} <:< ${To}.") sealed abstract class <:<[-From, +To] extends (From => To) with Serializable ... implicit def conforms[A]: A <:< A = ...
Thus, the implicit type <:<[A, B] can only be allowed if A is a subtype of B.
In this case, it can only be allowed if Option wrapped in another Option . In any other cases, a compilation error will occur:
scala> Option(42).flatten <console>:8: error: Cannot prove that Int <:< Option[B]. Option(42).flatten ^
chemikadze
source share