Closed
Description
minimized code
object Bug {
def (ab: (A, B)) pipe2[A, B, Z](f: (A, B) => Z): Z = f(ab._1, ab._2)
def (a: A) leftErr[A, B](b: B): A = (a, b).pipe2((a, b) => a) //Doesn't compile
def (a: A) leftOk1[A, B](b: B): A = Tuple2(a, b).pipe2((a, b) => a) //Compiles
def (a: A) leftOk2[A, B](b: B): A = {
val t = (a, b)
t.pipe2((a, b) => a) //Compiles
}
}
Error:
[error] -- [E007] Type Mismatch Error: D:\DevProjects\Incubating\Squeal\squeal\src\main\scala\squeal\TupleBug.scala:7:50
[error] 7 | def (a: A) leftErr[A, B](b: B): A = (a, b).pipe2((a, b) => a)
[error] | ^^^^^^^^^^^^^^^^^^^^^^^^^
[error] | Found: Any
[error] | Required: A
expectation
I would expect that all three would work. In most cases I can inline a val without any types without changing the behavior of the program.