A case like this will not compile
trait Test[A] {
type T
def apply(a: A): T
}
val test: Test[String] = s => s.length
type mismatch;
found : Int
required: Test[String]#T
changing the target type to specify the type member should not be needed, but does make things work in scala 3, however it does not help in scala 2
val test: Test[String] { type T = Int} = (s: String) => s.length
It would be nice if the compiler could infer T
in the first example given that it is inside a SAM trait.