From ff9f60f420c090b6716c927ab0359b082f2299de Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 6 Oct 2012 10:20:45 -0700 Subject: Fix for SI-6482, lost bounds in extension methods. That was a good one. How to create a new method with type parameters from multiple sources, herein. --- test/files/pos/t6482.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/files/pos/t6482.scala (limited to 'test/files/pos') 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 +} -- cgit v1.2.3