-
Notifications
You must be signed in to change notification settings - Fork 21
Infer result type using type of overridden method, if any (and not using the rhs) #7212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7212?orig=1 |
@adriaanm said: Paul Phillips It's interesting that you have some choices when looking for an unhelpful type to be inferred. Never let it be said the compiler is autocratic. You can have any color you want, as long as it's black or ebony.
|
@adriaanm said: |
@adriaanm said: |
@adriaanm said: |
@adriaanm said: |
@som-snytt said: val ref = new SimpleSpec with Reference with Property {
type ThisCommandLine = SpecCommandLine
protected def creator(args: List[String]): ThisCommandLine = new SpecCommandLine(args)
//def referenceSpec: Reference = this // perniciously, the type is required
def referenceSpec = this // not even used, could be ??? here
override def propMapper = new PropertyMapper(this)
} |
This could also be interesting to speed up compilation by using the inherited type rather than type checking the RHS. The decision point is in Too late for 2.13, though. |
I'm not sure if I should prefer the behavior of dotty... |
I've opened a ticket suggesting the Scala 3 migration guide mention this: scalacenter/scala-3-migration-guide#181 |
closing as out of scope for Scala 2 |
Worst possible resolution. Did I ever PR this? This is so obvious etc. |
perhaps someone would like to PR it under |
My duplicate ticket from 2013 was #8159 in case that inspires someone. I thought this already had a PR by lrytz or adriaanm. |
I came across this again because test https://github.com/scala/scala/blob/2.13.x/test/files/neg/t2441.scala for #2441 is fixed in Scala 3 under this change. I had forgotten I'd just been here during pandemic. |
linked PR changes the behavior, but only under |
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.)
The text was updated successfully, but these errors were encountered: