scala-library-next icon indicating copy to clipboard operation
scala-library-next copied to clipboard

LinearSeqOps suffers from brittle inheritance

Open som-snytt opened this issue 3 years ago • 0 comments

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.

som-snytt avatar Aug 16 '22 13:08 som-snytt