summaryrefslogtreecommitdiff
path: root/test/files/pos
diff options
context:
space:
mode:
authorAleksandar Prokopec <axel22@gmail.com>2012-02-16 13:34:06 +0100
committerAleksandar Prokopec <axel22@gmail.com>2012-02-16 13:34:06 +0100
commit53b05bb12f5a7a50448bcac9434389bf95273c45 (patch)
treed10140f4a3f2ea46dd39b47828c1326e9a61681e /test/files/pos
parentf2ccb43a844e484ae511c8cff3fbf534a0d86ebe (diff)
parent91148376049a152edec12348ff9b7e9e93e6ebe1 (diff)
downloadscala-53b05bb12f5a7a50448bcac9434389bf95273c45.tar.gz
scala-53b05bb12f5a7a50448bcac9434389bf95273c45.tar.bz2
scala-53b05bb12f5a7a50448bcac9434389bf95273c45.zip
Merge branch 'master' into execution-context
Conflicts: src/library/scala/package.scala
Diffstat (limited to 'test/files/pos')
-rw-r--r--test/files/pos/existentials-harmful.scala54
-rw-r--r--test/files/pos/existentials.scala22
-rw-r--r--test/files/pos/spec-Function1.scala2
-rw-r--r--test/files/pos/spec-groups.scala65
-rw-r--r--test/files/pos/specialize10.scala7
-rw-r--r--test/files/pos/t3999b.scala20
-rw-r--r--test/files/pos/t4336.scala19
-rw-r--r--test/files/pos/t531.scala4
-rw-r--r--test/files/pos/t532.scala4
-rw-r--r--test/files/pos/t5444.scala42
-rw-r--r--test/files/pos/trait-force-info.flags1
-rw-r--r--test/files/pos/trait-force-info.scala18
12 files changed, 253 insertions, 5 deletions
diff --git a/test/files/pos/existentials-harmful.scala b/test/files/pos/existentials-harmful.scala
new file mode 100644
index 0000000000..8722852e8a
--- /dev/null
+++ b/test/files/pos/existentials-harmful.scala
@@ -0,0 +1,54 @@
+// a.scala
+// Mon Jul 11 14:18:26 PDT 2011
+
+object ExistentialsConsideredHarmful {
+ class Animal(val name: String)
+ object Dog extends Animal("Dog")
+ object Sheep extends Animal("Sheep")
+
+ trait Tools[A] {
+ def shave(a: A): A
+ }
+ def tools[A](a: A): Tools[A] = null // dummy
+
+ case class TransportBox[A <: Animal](animal: A, tools: Tools[A]) {
+ def label: String = animal.name
+ }
+
+ // 1.
+ def carry[A <: Animal](box: TransportBox[A]): Unit = {
+ println(box.animal.name+" got carried away")
+ }
+
+ val aBox =
+ if (math.random < 0.5)
+ TransportBox(Dog, tools(Dog))
+ else
+ TransportBox(Sheep, tools(Sheep))
+
+ // 2.
+ //aBox.tools.shave(aBox.animal)
+
+ // Use pattern match to avoid opening the existential twice
+ aBox match {
+ case TransportBox(animal, tools) => tools.shave(animal)
+ }
+
+ abstract class BoxCarrier[R <: Animal](box: TransportBox[R]) {
+ def speed: Int
+
+ def talkToAnimal: Unit = println("The carrier says hello to"+box.animal.name)
+ }
+
+ // 3.
+ //val bc = new BoxCarrier(aBox) {
+
+ // Use pattern match to avoid opening the existential twice
+ // Type annotation on bc is required ... possible compiler bug?
+ // val bc : BoxCarrier[_ <: Animal] = aBox match {
+ val bc = aBox match {
+ case tb : TransportBox[a] => new BoxCarrier(tb) {
+ def speed: Int = 12
+ }
+ }
+}
diff --git a/test/files/pos/existentials.scala b/test/files/pos/existentials.scala
new file mode 100644
index 0000000000..0adbc701a6
--- /dev/null
+++ b/test/files/pos/existentials.scala
@@ -0,0 +1,22 @@
+/** All of these should work, some don't yet.
+ * !!!
+ */
+class A {
+ def f() = { case class Bob(); Bob }
+
+ val quux0 = f()
+ def quux1 = f()
+ // lazy val quux2 = f()
+ // def quux3 = {
+ // lazy val quux3a = f()
+ // quux3a
+ // }
+
+ val bippy0 = f _
+ def bippy1 = f _
+ // lazy val bippy2 = f _
+ // val bippy3 = {
+ // lazy val bippy3a = f _
+ // bippy3a
+ // }
+}
diff --git a/test/files/pos/spec-Function1.scala b/test/files/pos/spec-Function1.scala
index 7bdcd072b2..5b6af67a74 100644
--- a/test/files/pos/spec-Function1.scala
+++ b/test/files/pos/spec-Function1.scala
@@ -8,7 +8,7 @@
// generated by genprod on Wed Apr 23 10:06:16 CEST 2008 (with fancy comment) (with extra methods)
-package scala
+package scalabip
/** <p>
diff --git a/test/files/pos/spec-groups.scala b/test/files/pos/spec-groups.scala
new file mode 100644
index 0000000000..9b6359a982
--- /dev/null
+++ b/test/files/pos/spec-groups.scala
@@ -0,0 +1,65 @@
+import Specializable._
+
+class A[@specialized(Primitives) T](x: T) {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class B[@specialized(Everything) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class C[@specialized(Bits32AndUp) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class D[@specialized(Integral) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class E[@specialized(AllNumeric) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class F[@specialized(BestOfBreed) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
+class G[@specialized(Byte, Double, AnyRef) T] {
+ def f1[@specialized(Primitives) U](x: T, y: U) = ((x, y))
+ def f2[@specialized(Everything) U](x: T, y: U) = ((x, y))
+ def f3[@specialized(Bits32AndUp) U](x: T, y: U) = ((x, y))
+ def f4[@specialized(Integral) U](x: T, y: U) = ((x, y))
+ def f5[@specialized(AllNumeric) U](x: T, y: U) = ((x, y))
+ def f6[@specialized(BestOfBreed) U](x: T, y: U) = ((x, y))
+ def f7[@specialized(Byte, Double, AnyRef) U](x: T, y: U) = ((x, y))
+}
diff --git a/test/files/pos/specialize10.scala b/test/files/pos/specialize10.scala
new file mode 100644
index 0000000000..bbe197cda2
--- /dev/null
+++ b/test/files/pos/specialize10.scala
@@ -0,0 +1,7 @@
+trait Bippy[@specialized(
+ scala.Char, scala.Boolean, scala.Byte,
+ scala.Short, scala.Int, scala.Long,
+ scala.Float, scala.Double, scala.Unit,
+ scala.AnyRef) T] { }
+
+trait Bippy2[@specialized(Char, Boolean, Byte, Short, Int, Long, Float, Double, Unit, AnyRef) T] { }
diff --git a/test/files/pos/t3999b.scala b/test/files/pos/t3999b.scala
new file mode 100644
index 0000000000..d3fe108479
--- /dev/null
+++ b/test/files/pos/t3999b.scala
@@ -0,0 +1,20 @@
+object `package` {
+ trait Score { def toString : String }
+ trait Test[+T <: Score] { def apply(s : String) : T }
+
+ case class FT(f : Float) extends Score
+ implicit object FT extends Test[FT] { def apply(s : String) : FT = new FT(s.toFloat) }
+
+ case class IT(i : Int) extends Score
+ implicit object IT extends Test[IT] { def apply(s : String) : IT = new IT(s.toInt) }
+}
+
+class TT[+T <: Score](implicit val tb : Test[T]) {
+ def read(s : String) : T = tb(s)
+}
+
+object Tester {
+ val tt = new TT[FT]
+ val r = tt.read("1.0")
+ r.toString
+} \ No newline at end of file
diff --git a/test/files/pos/t4336.scala b/test/files/pos/t4336.scala
new file mode 100644
index 0000000000..e10d001585
--- /dev/null
+++ b/test/files/pos/t4336.scala
@@ -0,0 +1,19 @@
+object Main {
+ class NonGeneric {}
+ class Generic[T] {}
+
+ class Composite {
+ def contains(setup : Composite => Unit) : Composite = this
+ }
+
+ def generic[T](parent: Composite): Generic[T] = new Generic[T]
+ def nonGeneric(parent: Composite): NonGeneric = new NonGeneric
+
+ new Composite().contains(
+ nonGeneric // should have type Composite => NonGeneric
+ )
+
+ new Composite().contains(
+ generic[Int] // should have type Composite => Generic[Int]
+ )
+}
diff --git a/test/files/pos/t531.scala b/test/files/pos/t531.scala
index 02763e08f1..856926de4f 100644
--- a/test/files/pos/t531.scala
+++ b/test/files/pos/t531.scala
@@ -2,9 +2,9 @@ object Test extends App {
import scala.reflect._;
def titi = {
var truc = 0
- val tata: Code[()=>Unit] = () => {
+ val tata = Code.lift{() => {
truc = 6
- }
+ }}
()
}
}
diff --git a/test/files/pos/t532.scala b/test/files/pos/t532.scala
index 32649b1629..f864bbf45e 100644
--- a/test/files/pos/t532.scala
+++ b/test/files/pos/t532.scala
@@ -2,9 +2,9 @@ object Test extends App {
import scala.reflect._;
def titi: Unit = {
var truc = 0
- val tata: Code[()=>Unit] = () => {
+ val tata = Code.lift{() => {
truc = truc + 6
- }
+ }}
()
}
}
diff --git a/test/files/pos/t5444.scala b/test/files/pos/t5444.scala
new file mode 100644
index 0000000000..df6b2ce4f8
--- /dev/null
+++ b/test/files/pos/t5444.scala
@@ -0,0 +1,42 @@
+// /scala/trac/5444/a.scala
+// Mon Feb 13 21:01:45 PST 2012
+
+// Traits require identical names to reproduce.
+class Test {
+ def a() = {
+ trait T {
+ def x() = 1
+ }
+ trait U {
+ def x1() = 2
+ }
+ class Bippy extends T with U { def z() = x() + x1() }
+ new Bippy
+ }
+ def b() {
+ trait T {
+ def y() = 3
+ trait T2 {
+ def yy() = 10
+ }
+ }
+ trait U {
+ def y1() = 4
+ trait T3 {
+ def yy() = 11
+ }
+ }
+ class Bippy extends T with U { def z() = y() + y1() + (1 to (new T2 { }).yy()).map(_ + 1).sum }
+ (new Bippy).z()
+ }
+ def c() {
+ trait T {
+ def z() = 5
+ }
+ trait U {
+ def z1() = 6
+ }
+ (new Test with T with U).z1()
+ }
+}
+
diff --git a/test/files/pos/trait-force-info.flags b/test/files/pos/trait-force-info.flags
new file mode 100644
index 0000000000..eb4d19bcb9
--- /dev/null
+++ b/test/files/pos/trait-force-info.flags
@@ -0,0 +1 @@
+-optimise \ No newline at end of file
diff --git a/test/files/pos/trait-force-info.scala b/test/files/pos/trait-force-info.scala
new file mode 100644
index 0000000000..e01d225c84
--- /dev/null
+++ b/test/files/pos/trait-force-info.scala
@@ -0,0 +1,18 @@
+/** This does NOT crash unless it's in the interactive package.
+ */
+
+package scala.tools.nsc
+package interactive
+
+trait MyContextTrees {
+ val self: Global
+ val NoContext = self.analyzer.NoContext
+}
+//
+// error: java.lang.AssertionError: assertion failed: trait Contexts.NoContext$ linkedModule: <none>List()
+// at scala.Predef$.assert(Predef.scala:160)
+// at scala.tools.nsc.symtab.classfile.ClassfileParser$innerClasses$.innerSymbol$1(ClassfileParser.scala:1211)
+// at scala.tools.nsc.symtab.classfile.ClassfileParser$innerClasses$.classSymbol(ClassfileParser.scala:1223)
+// at scala.tools.nsc.symtab.classfile.ClassfileParser.classNameToSymbol(ClassfileParser.scala:489)
+// at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:757)
+// at scala.tools.nsc.symtab.classfile.ClassfileParser.sig2type$1(ClassfileParser.scala:789)