scala / scala-library-next

backwards-binary-compatible Scala standard library additions
Apache License 2.0
67 stars 17 forks source link

LinearSeqOps suffers from brittle inheritance #128

Open som-snytt opened 1 year ago

som-snytt commented 1 year ago

Transferred from https://github.com/scala/bug/issues/11697

LinearSeqOps isEmpty, head, tail are nominally abstract, but inherit concrete implementations that are broken.

It's not currently possible to enforce that these methods are overridden in subclasses of LinearSeqOps. Practically, they are overridden in the concrete subclass that extends both LinearSeq and LinearSeqOps.

A different set of internal API ("template methods") for coordinating these "fundamental methods" might improve the situation for a future iteration of the library.

Dotty has a ticket about how to handle abstract methods overriding concrete, so maybe that language change would suffice.