In this Scala 2.13 example:
import scala.language.implicitConversions
object Main2 extends App {
trait Foo {
type F = this.type => String
}
def fooA[A <: Foo](f: A#F, toString: A#F => String): String = toString(f)
def fooB[A <: Foo](f: A#F, toString: (A => String) => String): String = toString(f)
}
It fails with:
type mismatch;
found : _1.type => String where val _1: A
required: A => String
def fooB[A <: Foo](f: A#F, toString: (A => String) => String): String = toString(f)
Why is A => String not the same as _1.type => String where val _1: A?
Is it safe to cast f.asInstanceOf[(A => String)]?
Is there a concrete example where this doesn't work?