diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2015-11-19 13:31:00 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-02-01 13:23:19 +1000 |
commit | 907fe03e57b3cac4d0a67663edcd2b3b040e6ff8 (patch) | |
tree | c581c7b26ee2d8774ac0a084f56ee4f7464b1250 | |
parent | 78f0437ac06e71a94a38721751ef5d36ca62c062 (diff) | |
download | scala-907fe03e57b3cac4d0a67663edcd2b3b040e6ff8.tar.gz scala-907fe03e57b3cac4d0a67663edcd2b3b040e6ff8.tar.bz2 scala-907fe03e57b3cac4d0a67663edcd2b3b040e6ff8.zip |
SI-9542 Fix regression in value classes with enclosing refs
In SI-9473 / e2653736, I changed `mkAttributedRef` to avoid prefixing
references to statically owned symbols with a `ThisType`.
Turns out there was one place that depended on the old behaviour.
```
object Outer {
trait T
class C(val value: Any) extends AnyVal {
def foo(t: T) = expr
}
}
```
Is translated to:
```
object Outer {
trait T
class C(val value: Any) extends AnyVal {
def foo(t: T) = Outer.this.C.foo$extension(C.this, t)
}
object C {
def foo$extension($this: C, t: T) = expr
}
}
```
After the change, the forwarder was instead:
```
def foo(t: T) = Outer.C.foo$extension(C.this, t)
```
Note: this change is not actually necessary after the following
commit that makes subtyping unify the different module class
reference, that alone is enough to make the enclosed test
pass.
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala index d83cf68b38..9d02228ab5 100644 --- a/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala +++ b/src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala @@ -244,7 +244,10 @@ abstract class ExtensionMethods extends Transform with TypingTransformers { // These three lines are assembling Foo.bar$extension[T1, T2, ...]($this) // which leaves the actual argument application for extensionCall. - val sel = Select(gen.mkAttributedRef(companion), extensionMeth) + // SI-9542 We form the selection here from the thisType of the companion's owner. This is motivated + // by the test case, and is a valid way to construct the reference because we know that this + // method is also enclosed by that owner. + val sel = Select(gen.mkAttributedRef(companion.owner.thisType, companion), extensionMeth) val targs = origTpeParams map (_.tpeHK) val callPrefix = gen.mkMethodCall(sel, targs, This(origThis) :: Nil) |