diff options
author | James Iry <jamesiry@gmail.com> | 2013-01-29 16:58:54 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-01-29 16:58:54 -0800 |
commit | 7026376dcc87f531de84c99aa3e52068f5b10874 (patch) | |
tree | eeb9dbcb2553b5771cd337eb53cd5d97aa17aa35 /test | |
parent | c1dd8bbaa4cc688ab05fc325a02e20b91488a583 (diff) | |
parent | cfaa3b5408eb3e6eabe108d3adcb06fdcafe912a (diff) | |
download | scala-7026376dcc87f531de84c99aa3e52068f5b10874.tar.gz scala-7026376dcc87f531de84c99aa3e52068f5b10874.tar.bz2 scala-7026376dcc87f531de84c99aa3e52068f5b10874.zip |
Merge pull request #1912 from retronym/ticket/6651
SI-6651 Extension methods types may depend on the typed of the wrapped value
Diffstat (limited to 'test')
-rw-r--r-- | test/files/pos/t6651.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/files/pos/t6651.scala b/test/files/pos/t6651.scala new file mode 100644 index 0000000000..55a3b74e4c --- /dev/null +++ b/test/files/pos/t6651.scala @@ -0,0 +1,33 @@ +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.Dep + + def apply(dep: Dep)(d2: dep.type, foo: Int): (Dep, d2.type) = (d2, d2) + + // This generates dodgy code; note `ValueClass.this`: + // + // final def bounds$extension[D >: Nothing <: ValueClass.this.path.Dep, + // P >: Nothing <: Path] + // ($this: ValueClass[P]) + // (dep: D) + // (d2: dep.type, foo: Int): (D, d2.type) = scala.Tuple2.apply[D, d2.type](d2, d2); + // + // Nothing crashes down the line, but it certainly doesn't conform to best-practices. + // + // An better alternative would be to add a type parameter for the (singleton) type of + // the wrapped value. + def bounds[D <: Dep](dep: D)(d2: dep.type, foo: Int): (D, d2.type) = (d2, d2) +} + |