I did not draw these conclusions, so I can only guess. What I see: using the generate-an-apply-function approach can result in an ambiguity problem. This is already the case for case classes and I need to work around it from time to time. The question here is if we want to add ambiguity problems to code bases which are ambiguity free today in scala 2 when they upgrade/switch to dotty – this could make migrations much harder. Even worse, in some cases the behaviour could change as the generated apply method is more specific than the custom one. So potentially adding bugs when the code is compiled with dotty without noticing it.
IMO it would still be a feasible approach if we
- do not generate an apply in case of ambiguity and emit a warning in 3.0 and turn it into an error in 3.1 (i.e. generate the apply in all cases)
- emit a warning if the apply method is more specific (also for case classes)
However, I see additional problems with that approach:
- we generate companion objects for all classes even though we don’t need it
- sometimes I want to hide the constructor and provide my own apply method (factory method) and not provide the auto-generated one. For case classes there is no way to do this as far as I know, the public apply is always there. That’s kind of OK for case classes and for consistency reasons the same should apply to classes (if this approach is taken).
IMO the current approach where omitting new
is really the same as using new
is good. but I would like to see an easy way to delegate to the constructor from an apply (maybe something for 3.1 or did I miss something and it’s already there?).