, 6.26.4 " " spec , . . , ( Any) ( ) ( Int).
, reduceLeft.
, , :
scala> List(1,2).reduceLeft[Any](_.toString + _)
res26: Any = 12
inferencer:
scala> List(1,2).reduceLeft(_.toString + _)
<console>:8: error: type mismatch;
found : java.lang.String
required: Int
List(1,2).reduceLeft(_.toString + _)
, , , :
List(1,2).reduceLeft((_:Any).toString + (_:Any).toString)
-Ytyper-debug, :
List(1,2).reduceLeft(_+_)
, - , (Int, Int) => Int, _ + _ , B Int. :
typed immutable.this.List.apply[Int](1, 2).reduceLeft: [B >: Int](f: (B, Int) => B)B
adapted immutable.this.List.apply[Int](1, 2).reduceLeft: [B >: Int](f: (B, Int) => B)B to ?, undetparams=type B
typing ((x$1, x$2) => x$1.$plus(x$2)): pt = (Int, Int) => Int: undetparams=,
// some time later
typed ((x$1: Int, x$2: Int) => x$1.+(x$2)): (Int, Int) => Int
adapted ((x$1: Int, x$2: Int) => x$1.+(x$2)): (Int, Int) => Int to (Int, Int) => Int,
typed immutable.this.List.apply[Int](1, 2).reduceLeft[Int](((x$1: Int, x$2: Int) => x$1.+(x$2))): Int
, (Int, Int) => Int.