Rework insertion of stabilizing definitions#8716
Conversation
|
cc @som-snytt (alternative to PR #8208), @milessabin. @retronym does this come close to what you suggested in here scala/bug#11756 (comment)? |
df9b903 to
8cd15db
Compare
|
@retronym this is ready for a review. I'll try to also run it through the community build (had some seemingly unrelated issues before). |
|
I wonder if we could describe the way that stabiliizers are inserted in "spec-ese"? We should ensure that we align our implenetation here with Scala 3. |
|
@lrytz I'll give this some more thought and review tomorrow. A new typer mode together with new context state requires more than a little navel gazing! |
|
Community build is green (except for one unrelated failure) https://scala-ci.typesafe.com/job/scala-2.13.x-integrate-community-build/3215/ |
This comment has been minimized.
This comment has been minimized.
|
Ready for another review :) |
|
I tested the snapshot on my codebase and everything works great! Final blocker is now lifted and I'll be able to move up from TLS v2.12.4. |
This comment has been minimized.
This comment has been minimized.
Introduce a typer mode to know when we're type checking a qualifier
of a select, or a function part of an application. When a stabilizing
qualifier is created, insert it once we get back out of this mode.
In `x.y.foo(bar)`, if `foo` has a second implicit argument list, make
sure that the block with the stabilizer is only created after the
implicit is inferred, i.e., run `adapt` on `$stabilizer.foo(bar)`
to get `$stabilizer.foo(bar)(<implicit arg>)` first, then create
```
{
val $stabilizer = x.y
$stabilizer.foo(bar)(<implicit arg>)
}
```
Before, we would create
```
{
val $stabilizer = x.y
$stabilizer.foo(bar)
}
```
then assign a `MethodType` to the block, and run `adapt`. This worked in
some situations by chance, but not always.
|
Thank you all! |
Introduce a typer mode to know when we're type checking a qualifier
of a select, or a function part of an application. When a stabilizing
qualifier is created, insert it once we get back out of this mode.
In
x.y.foo(bar), iffoohas a second implicit argument list, makesure that the block with the stabilizer is only created after the
implicit is inferred, i.e., run
adapton$stabilizer.foo(bar)to get
$stabilizer.foo(bar)(<implicit arg>)first, then createBefore, we would create
then assign a
MethodTypeto the block, and runadapt. This worked insome situations by chance, but not always.
Fixes scala/bug#11756 and fixes scala/bug#11609 (tested also with shapeless)