Compat Scala 2: Abstract override
See original GitHub issueclass Seq
trait IterableOnceOps {
def toSeq: Seq = new Seq
}
trait IterableOps extends IterableOnceOps
trait SeqOps extends IterableOps {
def toSeq: Seq
}
class Foo extends SeqOps
The code snippet above compiles with Scala2 but not Dotty:
-- Error: tests/allan/Test.scala:53:6 ------------------------------------------
53 |class Foo extends SeqOps
| ^
| class Foo needs to be abstract, since def toSeq: => Seq is not defined
one error found
This pattern is used in the 2.13 collection library
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (11 by maintainers)
Top Results From Across the Web
Why is my abstract or overridden val null? | FAQ
Naturally when a val is overridden, it is not initialized more than once. So though x2 in the above example is seemingly defined...
Read more >scala - Why is "abstract override" required not ... - Stack Overflow
It may not be abstract unless it is overridden by a member declared abstract and override The combination of abstract and override tells...
Read more >Interface With Default Methods vs Abstract Class - Baeldung
Learn the differences between interfaces with default methods and abstract classes in Java.
Read more >Chapter 8. Classes - Oracle Help Center
Any of C's superclasses has an abstract method declared with package access, and there exists no method that overrides the abstract method from...
Read more >scala trait vs abstract class
Scala arrays are compatible with Scala sequences - we can pass an Array[T] where a Seq[T] is ... 2. 2022-10-23. 1. abstract class...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Only discussion related to this that I can remember is https://contributors.scala-lang.org/t/ability-to-make-a-parents-concrete-method-abstract/1255
It’s also pointed out in that thread that Scala 2 already does the “Java thing” when it comes to abstract classes.
In case that’s news to anyone.
Scala 2 allows widening the type in an abstract override, but that seems a pretty obscure feature