-
Notifications
You must be signed in to change notification settings - Fork 21
prefix method call expansion is ruining the dependent method types party #4518
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-4518?orig=1 |
@odersky said: |
@dragos said: |
@adriaanm said (edited on May 23, 2011 8:47:14 AM UTC): val broke_val = tempval.-:(new AnyRef {}) // type mismatch error only when assigning works around the bug... the prefix method call expansion seems to be ruining the dependent method types party smaller test case and typer output: object Test {
trait Foo[T]
trait Bar {
def -:(core: AnyRef): Foo[core.type] = error("")
}
val tempval: Bar = error("")
val cor: AnyRef = error("")
val ok : Foo[cor.type] = tempval.-:(cor)
val oops : Foo[cor.type] = cor -: tempval
} private[this] val ok: Test.Foo[Test.cor.type] = Test.this.tempval.-:(Test.this.cor);
<stable> <accessor> def ok: Test.Foo[Test.cor.type] = Test.this.ok;
private[this] val oops: Test.Foo[Test.cor.type] = {
<synthetic> val x$1: AnyRef = Test.this.cor;
Test.this.tempval.-:(x$1)
};
<stable> <accessor> def oops: Test.Foo[Test.cor.type] = Test.this.oops |
It wasn't fixed under the linked ticket after all. |
The code in this example can be compiled. Also, the |
It is added as a pos test in the linked PR, which may make it into 2.13.7. Presumably it did not compile on pre-release 2.13. Edit: I couldn't reproduce whatever failure I witnessed. Feb 2019 was a couple of computers ago. I tried M5 and RC1. |
It's the Adriaan reduction that fails. That is because rassoc rewrite extracts the expression in parser, so some context is lost; the linked PR rewrites in typer. |
@som-snytt (care to revise the issue title, if we're leaving this open? the current title attracted my attention since |
I'm glad I left a few breadcrumbs for future self. Here's Adriaan's reduction again: object Test {
trait Foo[T]
trait Bar {
def -:(core: AnyRef): Foo[core.type] = error("")
}
val tempval: Bar = error("")
val cor: AnyRef = error("")
val ok : Foo[cor.type] = tempval.-:(cor)
val oops : Foo[cor.type] = cor -: tempval
def error(s: String) = ???
} currently 2.13.12
I see that is a pos test on my branch but not yet pushed to the PR. I will need to catch up because
oh man, that's sbt 1.8.2, I have to downgrade my jdk. OK, it compiles on that branch. I suspect Lukas was just giving me a hard time on the last mile. It will take me a bit to rebase because I'm starting season 2 of Dawson's Creek, they're literally still kissing. I think cliffhanger is specialized lingo for whatever generation that is. |
I can't improve on Adriaan's description, except one tweak for length. |
=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===
scalac -Xexperimental Broke.scala
=== What is the expected behavior? ===
Compiles without error, as it did with 2.7.7 and 2.8.1
=== What do you see instead? ===
Broke.scala:6: error: type mismatch;
found : Broke.this.tempval.type with Broke.this.Foo[x$$2.type(in value broke_val)] where type x$$2.type(in value broke_val) <: java.lang.Object with Singleton
required: Broke.this.tempval.type with Broke.this.Foo[x$$2.type(in value broke_val)] forSome { type x$$2.type(in value broke_val) <: java.lang.Object with Singleton }
val broke_val = new AnyRef {} -: tempval // type mismatch error only when assigning
^
one error found
=== Additional information ===
(for instance, a link to a relevant mailing list discussion)
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: