summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-01-16 18:56:24 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-01-29 23:44:38 +0100
commitcfaa3b5408eb3e6eabe108d3adcb06fdcafe912a (patch)
treebbd68d2a567dfeb4477c19a1dc5518262bc7a5e4 /test/files
parent45ccdc5b89f8fb47a418c8c1304e16afc4d14e2c (diff)
downloadscala-cfaa3b5408eb3e6eabe108d3adcb06fdcafe912a.tar.gz
scala-cfaa3b5408eb3e6eabe108d3adcb06fdcafe912a.tar.bz2
scala-cfaa3b5408eb3e6eabe108d3adcb06fdcafe912a.zip
SI-6551 Expand test case into uncomfortable areas.
trait T { type U } class A(val a: T) extends AnyVal { def foo[TT <: a.U] = 0 } It works! But it's pure serendipity. After extmethods, the careful student of ASTs will find: object A { final def foo$extension[TT >: Nothing <: A.this.a.U]($this: A): Int = 0; } `A.this` doesn't belong. For now we just include this case under our test umbrella.
Diffstat (limited to 'test/files')
-rw-r--r--test/files/pos/t6651.scala29
1 files changed, 18 insertions, 11 deletions
diff --git a/test/files/pos/t6651.scala b/test/files/pos/t6651.scala
index 394e3fe689..55a3b74e4c 100644
--- a/test/files/pos/t6651.scala
+++ b/test/files/pos/t6651.scala
@@ -3,8 +3,8 @@ class YouAreYourself[A <: AnyRef](val you: A) extends AnyVal {
}
object Test {
- val s = ""
- val s1: s.type = new YouAreYourself[s.type](s).yourself
+ val s = ""
+ val s1: s.type = new YouAreYourself[s.type](s).yourself
}
trait Path {
@@ -12,15 +12,22 @@ trait Path {
}
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)
-}
+ import path.Dep
-object TestValueClass {
- object P extends Path {
- type Dep = String
- }
+ def apply(dep: Dep)(d2: dep.type, foo: Int): (Dep, d2.type) = (d2, d2)
- val s: String = ""
- new ValueClass(P).apply(s)(s, 0): (String, s.type)
+ // 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)
}
+