diff options
author | James Iry <jamesiry@gmail.com> | 2013-02-03 13:10:41 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-02-03 13:10:41 -0800 |
commit | 786a686b78e7bffb452c6508a83b69ad83849819 (patch) | |
tree | a60d06d491a4ba3bb053b76cd1cbc3271fc79f8e /test/files | |
parent | a4ace4b4d99e8fc2332c4ee746998056da110b50 (diff) | |
parent | 374c912a1440193b06fc6fd74b39063949b2c086 (diff) | |
download | scala-786a686b78e7bffb452c6508a83b69ad83849819.tar.gz scala-786a686b78e7bffb452c6508a83b69ad83849819.tar.bz2 scala-786a686b78e7bffb452c6508a83b69ad83849819.zip |
Merge pull request #1976 from retronym/backport/1468
[backport] SI-6428 / SI-7022 Value class with bounds
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/pos/t6482.scala | 11 | ||||
-rw-r--r-- | test/files/pos/t7022.scala | 9 |
2 files changed, 20 insertions, 0 deletions
diff --git a/test/files/pos/t6482.scala b/test/files/pos/t6482.scala new file mode 100644 index 0000000000..24ea38e519 --- /dev/null +++ b/test/files/pos/t6482.scala @@ -0,0 +1,11 @@ +final class TraversableOnceOps[+A](val collection: TraversableOnce[A]) extends AnyVal { + def reduceLeftOption[B >: A](op: (B, A) => B): Option[B] = + if (collection.isEmpty) None else Some(collection.reduceLeft[B](op)) +} +// error: type arguments [B] do not conform to method reduceLeft's type parameter bounds [B >: A] +// if (collection.isEmpty) None else Some(collection.reduceLeft[B](op)) +// ^ + +class Foo[+A <: AnyRef](val xs: List[A]) extends AnyVal { + def baz[B >: A](x: B): List[B] = x :: xs +} diff --git a/test/files/pos/t7022.scala b/test/files/pos/t7022.scala new file mode 100644 index 0000000000..0609e2d250 --- /dev/null +++ b/test/files/pos/t7022.scala @@ -0,0 +1,9 @@ +class Catch[+T] { + def either[U >: T](body: => U): Either[Throwable, U] = ??? +} + +object Test { + implicit class RichCatch[T](val c: Catch[T]) extends AnyVal { + def validation[U >: T](u: => U): Either[Throwable, U] = c.either(u) + } +} |