Issues with removing `new`

As Scala 3 allows to call constructors without using new, I tried to remove all the new keywords in a project of mine. However, I ran into a couple of issues:

  • Objects cannot be constructed from type aliases without new.
  • mutable.HashSet[Int]() is not the same as new mutable.HashSet[Int]: The former builds from varargs, so creates a sequence and a builder.
  • new mutable.ArrayBuffer[String](n) (with n an integer) won’t compile without the new.

I conclude that there are some loose ends. However, it is not clear to me what is intentional behavior, what is a bug, and whether some changes to the language and/or the standard library may be necessary to improve user experience.


first bullet is Creator application is lost on type alias · Issue #10862 · lampepfl/dotty · GitHub

1 Like