I get an error when I use the map function immediately after converting the type with scala, but I don't understand the cause.

// error
val list = List (1,2,3,4,2) .toSet.map (n =>n + 1)
println (list)
// OK
val list = List (1,2,3,4,2)
val set = list.toSet
println (set.map (n =>n + 1)

What is the theory behind this difference?

Works well with Seq
// OK
val seq = List (1,2,3,4,2) .toSeq.map (n =>n + 1)
println (seq)