diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-01-16 18:04:03 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-01-29 23:44:38 +0100 |
commit | 45ccdc5b89f8fb47a418c8c1304e16afc4d14e2c (patch) | |
tree | 2457958734caddfcd109086fe68bdb97bdce571c /test | |
parent | eff78b852e8b866badf9b9738f896c2a31c05474 (diff) | |
download | scala-45ccdc5b89f8fb47a418c8c1304e16afc4d14e2c.tar.gz scala-45ccdc5b89f8fb47a418c8c1304e16afc4d14e2c.tar.bz2 scala-45ccdc5b89f8fb47a418c8c1304e16afc4d14e2c.zip |
SI-6651 Substitute `this` in extension method sigs
This allows for the likes of:
class A[X](val x: X) extends AnyVal {
def foo(xy: x.Y) {}
}
We have to do this in both directions, when synthesizing
the extension method in `Extender#transform`, and later on
when Erasure tries to find the corresponding extension
methods by backing out the original signatures from
the signatures of the synthesized methods in the companion.
In the first case, we have to be careful to use a stable
reference to the `self` parameter, which can satisfy the
dependent types.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/pos/t6651.scala | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/files/pos/t6651.scala b/test/files/pos/t6651.scala new file mode 100644 index 0000000000..394e3fe689 --- /dev/null +++ b/test/files/pos/t6651.scala @@ -0,0 +1,26 @@ +class YouAreYourself[A <: AnyRef](val you: A) extends AnyVal { + def yourself: you.type = you +} + +object Test { + val s = "" + val s1: s.type = new YouAreYourself[s.type](s).yourself +} + +trait Path { + type Dep <: AnyRef +} + +final class ValueClass[P <: Path](val path: P) extends AnyVal { + import path._ + def apply(dep: Dep)(d2: dep.type, foo: Int): (Dep, d2.type) = (d2 ,d2) +} + +object TestValueClass { + object P extends Path { + type Dep = String + } + + val s: String = "" + new ValueClass(P).apply(s)(s, 0): (String, s.type) +} |