def foo(x: Int, f: Unit => Int) = println(f()) foo(2, { Unit => 3 + 4 }) // case 1 def loop: Int = 7 foo(2, loop) // does not compile changing loop to // c
In case 1 and 2 above, the return value of loop rather than loop itself is type checked for the second argument to foo and fails: Int != Unit => Int
The change to loop has a typo.