Due to Scala's syntactic rules you'll need to enclose those in brackets.
((500 m) + (10 km)) toKm
For code style consistency and other reasons I would however advise against ever using infix notation for anything other than symbolic operators (+
in this case), i.e.:
(500.m + 10.km).toKm