diff options
Diffstat (limited to 'test/files')
26 files changed, 245 insertions, 14 deletions
diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check index 894eabc442..6c9482e537 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.check +++ b/test/files/neg/macro-invalidsig-context-bounds.check @@ -1,4 +1,4 @@ -Impls_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences
- def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = {
- ^
-one error found
+Impls_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences + def foo[U: c.AbsTypeTag: Numeric](c: Ctx) = { + ^ +one error found diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check index 029b8a4634..98b3167b7a 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.check +++ b/test/files/neg/macro-invalidsig-implicit-params.check @@ -1,4 +1,4 @@ -Impls_Macros_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences
- def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = {
- ^
-one error found
+Impls_Macros_1.scala:5: error: macro implementations cannot have implicit parameters other than AbsTypeTag evidences + def foo_targs[T, U: c.AbsTypeTag](c: Ctx)(implicit x: c.Expr[Int]) = { + ^ +one error found diff --git a/test/files/neg/newpat_unreachable.check b/test/files/neg/newpat_unreachable.check new file mode 100644 index 0000000000..08453cac19 --- /dev/null +++ b/test/files/neg/newpat_unreachable.check @@ -0,0 +1,27 @@ +newpat_unreachable.scala:6: error: patterns after a variable pattern cannot match (SLS 8.1.1) +If you intended to match against parameter b of method contrivedExample, you must use backticks, like: case `b` => + case b => println("matched b") + ^ +newpat_unreachable.scala:7: error: unreachable code due to variable pattern 'b' on line 6 +If you intended to match against parameter c of method contrivedExample, you must use backticks, like: case `c` => + case c => println("matched c") + ^ +newpat_unreachable.scala:8: error: unreachable code due to variable pattern 'b' on line 6 +If you intended to match against value d in class A, you must use backticks, like: case `d` => + case d => println("matched d") + ^ +newpat_unreachable.scala:9: error: unreachable code due to variable pattern 'b' on line 6 + case _ => println("matched neither") + ^ +newpat_unreachable.scala:22: error: patterns after a variable pattern cannot match (SLS 8.1.1) +If you intended to match against parameter b of method g, you must use backticks, like: case `b` => + case b => 1 + ^ +newpat_unreachable.scala:23: error: unreachable code due to variable pattern 'b' on line 22 +If you intended to match against parameter c of method h, you must use backticks, like: case `c` => + case c => 2 + ^ +newpat_unreachable.scala:24: error: unreachable code due to variable pattern 'b' on line 22 + case _ => 3 + ^ +7 errors found diff --git a/test/files/neg/newpat_unreachable.flags b/test/files/neg/newpat_unreachable.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/newpat_unreachable.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/newpat_unreachable.scala b/test/files/neg/newpat_unreachable.scala new file mode 100644 index 0000000000..c9cc85cec6 --- /dev/null +++ b/test/files/neg/newpat_unreachable.scala @@ -0,0 +1,29 @@ +object Test { + class A { + val d = 55 + + def contrivedExample[A, B, C](a: A, b: B, c: C): Unit = a match { + case b => println("matched b") + case c => println("matched c") + case d => println("matched d") + case _ => println("matched neither") + } + + def correctExample[A, B, C](a: A, b: B, c: C): Unit = a match { + case `b` => println("matched b") + case `c` => println("matched c") + case `d` => println("matched d") + case _ => println("matched neither") + } + + def f[A](a: A) = { + def g[B](b: B) = { + def h[C](c: C) = a match { + case b => 1 + case c => 2 + case _ => 3 + } + } + } + } +} diff --git a/test/files/neg/pat_unreachable.check b/test/files/neg/pat_unreachable.check index 4e1463d591..c5706b7fad 100644 --- a/test/files/neg/pat_unreachable.check +++ b/test/files/neg/pat_unreachable.check @@ -4,4 +4,10 @@ pat_unreachable.scala:5: error: unreachable code pat_unreachable.scala:9: error: unreachable code case Seq(x, y) => List(x, y) ^ -two errors found +pat_unreachable.scala:23: error: unreachable code + case c => println("matched c") + ^ +pat_unreachable.scala:24: error: unreachable code + case _ => println("matched neither") + ^ +four errors found diff --git a/test/files/neg/pat_unreachable.scala b/test/files/neg/pat_unreachable.scala index fc0fd41920..1f402e5212 100644 --- a/test/files/neg/pat_unreachable.scala +++ b/test/files/neg/pat_unreachable.scala @@ -8,7 +8,7 @@ object Test extends App { case Seq(x, y, _*) => x::y::Nil case Seq(x, y) => List(x, y) } - + def not_unreachable(xs:Seq[Char]) = xs match { case Seq(x, y, _*) => x::y::Nil case Seq(x) => List(x) @@ -17,4 +17,10 @@ object Test extends App { case Seq(x, y) => x::y::Nil case Seq(x, y, z, _*) => List(x,y) } + + def contrivedExample[A, B, C](a: A, b: B, c: C): Unit = a match { + case b => println("matched b") + case c => println("matched c") + case _ => println("matched neither") + } } diff --git a/test/files/neg/t5148.check b/test/files/neg/t5148.check index 96eb1fd364..6edfdf2b1e 100644 --- a/test/files/neg/t5148.check +++ b/test/files/neg/t5148.check @@ -1,2 +1,3 @@ -error: bad reference while unpickling Imports.class: term memberHandlers not found in scala.tools.nsc.interpreter.IMain -one error found +error: bad symbolic reference to value global in class IMain - referenced from t5148.scala (a classfile may be missing) +error: bad symbolic reference to value memberHandlers in class IMain - referenced from t5148.scala (a classfile may be missing) +two errors found diff --git a/test/files/neg/t6048.check b/test/files/neg/t6048.check index 051f41877e..5bdf2eca88 100644 --- a/test/files/neg/t6048.check +++ b/test/files/neg/t6048.check @@ -4,7 +4,10 @@ t6048.scala:3: error: unreachable code t6048.scala:8: error: unreachable code case _ if false => x // unreachable ^ -t6048.scala:14: error: unreachable code +t6048.scala:13: error: patterns after a variable pattern cannot match (SLS 8.1.1) + case _ => x + ^ +t6048.scala:14: error: unreachable code due to variable pattern on line 13 case 5 if true => x // unreachable ^ -three errors found +four errors found diff --git a/test/files/neg/t6214.check b/test/files/neg/t6214.check new file mode 100644 index 0000000000..6349a3e71c --- /dev/null +++ b/test/files/neg/t6214.check @@ -0,0 +1,4 @@ +t6214.scala:5: error: missing parameter type + m { s => case class Foo() } + ^ +one error found diff --git a/test/files/neg/t6214.scala b/test/files/neg/t6214.scala new file mode 100644 index 0000000000..734acda35e --- /dev/null +++ b/test/files/neg/t6214.scala @@ -0,0 +1,7 @@ +object Test { + def m(f: String => Unit) = 0 + def m(f: Int => Unit) = 0 + def foo { + m { s => case class Foo() } + } +} diff --git a/test/files/pos/inline-access-levels.flags b/test/files/pos/inline-access-levels.flags new file mode 100644 index 0000000000..882f40f050 --- /dev/null +++ b/test/files/pos/inline-access-levels.flags @@ -0,0 +1 @@ +-optimise -Xfatal-warnings -Yinline-warnings diff --git a/test/files/pos/inline-access-levels/A_1.scala b/test/files/pos/inline-access-levels/A_1.scala new file mode 100644 index 0000000000..479fe0fc71 --- /dev/null +++ b/test/files/pos/inline-access-levels/A_1.scala @@ -0,0 +1,10 @@ +package test + +object A { + + private var x: Int = 0 + + @inline def actOnX(f: Int => Int) = { + x = f(x) + } +} diff --git a/test/files/pos/inline-access-levels/Test_2.scala b/test/files/pos/inline-access-levels/Test_2.scala new file mode 100644 index 0000000000..12c9eb540f --- /dev/null +++ b/test/files/pos/inline-access-levels/Test_2.scala @@ -0,0 +1,11 @@ +package test + +object Test { + + def main(args: Array[String]) { + + A.actOnX(_ + 1) + + } + +} diff --git a/test/files/pos/t5756.scala b/test/files/pos/t5756.scala new file mode 100644 index 0000000000..45960fa8bd --- /dev/null +++ b/test/files/pos/t5756.scala @@ -0,0 +1,6 @@ +import scala.reflect.runtime.universe._ + +object Test extends App { + def tagme[T: TypeTag](x: T) = typeTag[T] + val foo = tagme{object Bar; Bar} +}
\ No newline at end of file diff --git a/test/files/pos/t6022b.scala b/test/files/pos/t6022b.scala new file mode 100644 index 0000000000..6ceb928162 --- /dev/null +++ b/test/files/pos/t6022b.scala @@ -0,0 +1,20 @@ +trait A +trait B +trait C +trait AB extends B with A + +// two types are mutually exclusive if there is no equality symbol whose constant implies both +object Test extends App { + def foo(x: Any) = x match { + case _ : C => println("C") + case _ : AB => println("AB") + case _ : (A with B) => println("AB'") + case _ : B => println("B") + case _ : A => println("A") + } + + foo(new A {}) + foo(new B {}) + foo(new AB{}) + foo(new C {}) +} diff --git a/test/files/pos/t6184.scala b/test/files/pos/t6184.scala new file mode 100644 index 0000000000..83a1306aca --- /dev/null +++ b/test/files/pos/t6184.scala @@ -0,0 +1,7 @@ +trait Foo[TroubleSome] { + type T <: Foo[TroubleSome] + + this match { + case e: Foo[_]#T => ??? + } +}
\ No newline at end of file diff --git a/test/files/pos/t6201.scala b/test/files/pos/t6201.scala new file mode 100644 index 0000000000..366c1f26eb --- /dev/null +++ b/test/files/pos/t6201.scala @@ -0,0 +1,13 @@ +class Test { + class Foo1 { + def must(x: scala.xml.Elem) = () + } + + class Foo2 { + def must(x: Int) = () + } + implicit def toFoo1(s: scala.xml.Elem) = new Foo1() + implicit def toFoo2(s: scala.xml.Elem) = new Foo2() + + def is: Unit = { (<a>{"a"}</a>).must(<a>{"b"}</a>) } +}
\ No newline at end of file diff --git a/test/files/pos/t6204-a.scala b/test/files/pos/t6204-a.scala new file mode 100644 index 0000000000..bd8d5c437e --- /dev/null +++ b/test/files/pos/t6204-a.scala @@ -0,0 +1,9 @@ +import scala.reflect.runtime.universe._ + +object Bish { + def m { + object Bash { + typeOf[Option[_]] + } + } +}
\ No newline at end of file diff --git a/test/files/pos/t6204-b.scala b/test/files/pos/t6204-b.scala new file mode 100644 index 0000000000..86094d1a19 --- /dev/null +++ b/test/files/pos/t6204-b.scala @@ -0,0 +1,10 @@ +import scala.reflect.runtime.universe._ + +object Bosh { + def Besh { + new { + val t = typeOf[Option[_]] + val x = t + } + } +}
\ No newline at end of file diff --git a/test/files/run/t6197.check b/test/files/run/t6197.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t6197.check diff --git a/test/files/run/t6197.scala b/test/files/run/t6197.scala new file mode 100644 index 0000000000..5ab4b002d7 --- /dev/null +++ b/test/files/run/t6197.scala @@ -0,0 +1,21 @@ +import scala.collection.immutable._ + +object Test extends App { + + // test that a HashTrieSet with one leaf element is not created! + val x = HashSet.empty + 1 + 2 + if(x.getClass.getSimpleName != "HashTrieSet") + println("A hash set containing two non-colliding values should be a HashTrieSet") + + val y = x - 1 + if(y.getClass.getSimpleName != "HashSet1") + println("A hash set containing one element should always use HashSet1") + + // it is pretty hard to test that the case where a HashTrieSet has one element which + // is itself of type HashTrieS t. That is because the improve hash function makes it very difficult + // to find keys that will have hashes that are close together. + // + // However, it is also not necessary. Removing the ability of a HashTrieSet to have + // one child of type HashTrieSet completely breaks the HashSet, so that many other + // tests fail +} diff --git a/test/files/run/t6198.check b/test/files/run/t6198.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t6198.check diff --git a/test/files/run/t6198.scala b/test/files/run/t6198.scala new file mode 100644 index 0000000000..5aa8f1c1cf --- /dev/null +++ b/test/files/run/t6198.scala @@ -0,0 +1,24 @@ +import scala.collection.immutable._ + +object Test extends App { + // test that ListSet.tail does not use a builder + // we can't test for O(1) behavior, so the best we can do is to + // check that ls.tail always returns the same instance + val ls = ListSet.empty[Int] + 1 + 2 + + if(ls.tail ne ls.tail) + println("ListSet.tail should not use a builder!") + + // class that always causes hash collisions + case class Collision(value:Int) { override def hashCode = 0 } + + // create a set that should have a collison + val x = HashSet.empty + Collision(0) + Collision(1) + if(x.getClass.getSimpleName != "HashSetCollision1") + println("HashSet of size >1 with collisions should use HashSetCollision") + + // remove the collision again by removing all but one element + val y = x - Collision(0) + if(y.getClass.getSimpleName != "HashSet1") + println("HashSet of size 1 should use HashSet1" + y.getClass) +} diff --git a/test/files/run/t6223.check b/test/files/run/t6223.check new file mode 100644 index 0000000000..90ec019407 --- /dev/null +++ b/test/files/run/t6223.check @@ -0,0 +1,4 @@ +bar +bar$mcI$sp +bar$mIc$sp +bar$mIcI$sp diff --git a/test/files/run/t6223.scala b/test/files/run/t6223.scala new file mode 100644 index 0000000000..4ab7c832e6 --- /dev/null +++ b/test/files/run/t6223.scala @@ -0,0 +1,11 @@ +class Foo[@specialized(Int) A](a:A) { + def bar[@specialized(Int) B](f:A => B) = new Foo(f(a)) +} + +object Test { + def main(args:Array[String]) { + val f = new Foo(333) + val ms = f.getClass().getDeclaredMethods() + ms.foreach(m => println(m.getName)) + } +} |