From 3ee6b3653f8c25d7d6b19b9f5d4af7fa082146a8 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Thu, 18 Jun 2009 17:19:55 +0000 Subject: Specialization landed in trunk. --- test/files/pos/spec-Function1.scala | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/files/pos/spec-Function1.scala (limited to 'test/files/pos/spec-Function1.scala') diff --git a/test/files/pos/spec-Function1.scala b/test/files/pos/spec-Function1.scala new file mode 100644 index 0000000000..b749be0ba7 --- /dev/null +++ b/test/files/pos/spec-Function1.scala @@ -0,0 +1,50 @@ + +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id: Function1.scala 17163 2009-02-20 08:05:31Z dragos $ + +// generated by genprod on Wed Apr 23 10:06:16 CEST 2008 (with fancy comment) (with extra methods) + +package scala + + +/**

+ * Function with 1 parameters. + *

+ *

+ In the following example the definition of + * succ is a shorthand for the anonymous class definition + * anonfun1: + *

+ *
+ *  object Main extends Application {
+ *
+ *    val succ = (x: Int) => x + 1
+ *
+ *    val anonfun1 = new Function1[Int, Int] {
+ *      def apply(x: Int): Int = x + 1
+ *    }
+ *
+ *    println(succ(0))
+ *    println(anonfun1(0))
+ *  }
+ */ +trait Function1[@specialized -T1, @specialized +R] extends AnyRef { self => + def apply(v1:T1): R + override def toString() = "" + + /** (f compose g)(x) == f(g(x)) + */ + def compose[A](g: A => T1): A => R = { x => apply(g(x)) } + + /** (f andThen g)(x) == g(f(x)) + */ + def andThen[A](g: R => A): T1 => A = { x => g(apply(x)) } + +} -- cgit v1.2.3