-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
scala/scala
#9891Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)has PRinfer
Milestone
Description
An old email for which I never opened a ticket. It is undesirable that implementing an abstract method with an implementation like sys.error("no implementation yet") should force all subclasses to throw an exception. It is extremely unlikely anyone would want this "most specific type" to be inferred as the return type of a method for which less exceptional return type is already known (i.e. I'm not talking about def ??? which is born in the same location as the exception; I'm talking about any method for which there is an abstract or concrete implementation in a superclass.)
In the following, how does one define foo in class B such that:
1) class A's foo definitions can be swapped without modifying B
2) class C compiles
Can you? I can't. But I should be able to.
class A {
def foo = new A
// def foo = new B
}
class B extends A {
override def foo = sys.error("")
}
class C extends B {
override def foo = new C
}
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)has PRinfer