Missing something obvious with if statement?

There is a subtle difference between

val x = e: T

and

val x: T = e

It is almost always the case that one requires the former style of
annotation
in ATS.

The latter only checks that the type of e is a subtype of T.