summaryrefslogtreecommitdiff
path: root/test/files/pos/tcpoly_infer_ticket474.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2009-10-22 17:04:20 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2009-10-22 17:04:20 +0000
commitbf584e53207b837a3103a59614177ba39f06015e (patch)
treee68eeb41c745ccc848c5fbcd505249880daf021f /test/files/pos/tcpoly_infer_ticket474.scala
parenta2eab2215a7671e8abd8189ccc59388dffc1f3de (diff)
downloadscala-bf584e53207b837a3103a59614177ba39f06015e.tar.gz
scala-bf584e53207b837a3103a59614177ba39f06015e.tar.bz2
scala-bf584e53207b837a3103a59614177ba39f06015e.zip
the essence of tcpoly inference + test cases
fixes to check files and removed nonapplicable test case Tuple2 impl, but commented out so that we can bootstrap whitespace...
Diffstat (limited to 'test/files/pos/tcpoly_infer_ticket474.scala')
-rw-r--r--test/files/pos/tcpoly_infer_ticket474.scala27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/files/pos/tcpoly_infer_ticket474.scala b/test/files/pos/tcpoly_infer_ticket474.scala
new file mode 100644
index 0000000000..8c9be4d5c4
--- /dev/null
+++ b/test/files/pos/tcpoly_infer_ticket474.scala
@@ -0,0 +1,27 @@
+trait Builder[C[_], T] {
+ def +=(x: T)
+ def finalise: C[T]
+}
+
+trait Buildable[C[_]] {
+ def builder[T]: Builder[C,T]
+}
+
+object Test {
+
+ implicit object buildableList extends Buildable[List] {
+ def builder[T] = new Builder[List,T] {
+ val buf = new scala.collection.mutable.ListBuffer[T]
+ def +=(x: T) = buf += x
+ def finalise = buf.toList
+ }
+ }
+
+ def foo[C[_],T](x: T)(implicit b: Buildable[C]): C[T] = {
+ val builder = b.builder[T]
+ builder += x
+ builder.finalise
+ }
+
+ val l: List[Int] = foo(8)
+} \ No newline at end of file