diff options
Diffstat (limited to 'test')
72 files changed, 721 insertions, 68 deletions
diff --git a/test/files/pos/spec-List.scala b/test/disabled/pos/spec-List.scala index 04ab7d1543..04ab7d1543 100644 --- a/test/files/pos/spec-List.scala +++ b/test/disabled/pos/spec-List.scala diff --git a/test/files/jvm/actor-sync-send-timeout.scala b/test/files/jvm/actor-sync-send-timeout.scala new file mode 100644 index 0000000000..ed330900b2 --- /dev/null +++ b/test/files/jvm/actor-sync-send-timeout.scala @@ -0,0 +1,47 @@ +import scala.actors.Actor + +/* This test is a regression test for SI-4759. + */ +object Test { + val Runs = 5 + + def main(args: Array[String]) = { + var i = 0 + while (i < Runs) { + i += 1 + A1 ! 1 + Thread.sleep(500) + } + //println("done sending to A1") + } +} + +object A2 extends Actor { + this.start() + def act() { + loop { + react { + case 'stop => + //println("A2 exiting") + exit() + case _ => + } + } + } +} + +object A1 extends Actor { + this.start() + def act() { + var i = 0 + loopWhile(i < Test.Runs) { + i += 1 + react { + case any => + A2 !? (500, any) + if (i == Test.Runs) + A2 ! 'stop + } + } + } +} diff --git a/test/files/jvm/manifests.check b/test/files/jvm/manifests.check index 3b8ca5b5b1..54f504b929 100644 --- a/test/files/jvm/manifests.check +++ b/test/files/jvm/manifests.check @@ -29,7 +29,7 @@ x=Foo, m=Foo[scala.collection.immutable.List[Int]] x=Foo, m=Foo[Foo[Int]] x=Foo, m=Foo[scala.collection.immutable.List[Foo[Int]]] -x=Test1$$anon$1, m=Test1$$anon$1 +x=Test1$$anon$1, m=Object with Bar[java.lang.String] ()=() true=true diff --git a/test/files/neg/abstract-inaccessible.check b/test/files/neg/abstract-inaccessible.check new file mode 100644 index 0000000000..42b98ac026 --- /dev/null +++ b/test/files/neg/abstract-inaccessible.check @@ -0,0 +1,13 @@ +abstract-inaccessible.scala:5: error: method implementMe in trait YourTrait references private[foo] trait Bippy. +Classes which cannot access Bippy may be unable to provide a concrete implementation of implementMe. + def implementMe(f: Int => (String, Bippy)): Unit + ^ +abstract-inaccessible.scala:6: error: method overrideMe in trait YourTrait references private[foo] trait Bippy. +Classes which cannot access Bippy may be unable to override overrideMe. + def overrideMe[T <: Bippy](x: T): T = x + ^ +abstract-inaccessible.scala:7: error: method overrideMeAlso in trait YourTrait references private[foo] trait Bippy. +Classes which cannot access Bippy may be unable to override overrideMeAlso. + def overrideMeAlso(x: Map[Int, Set[Bippy]]) = 5 + ^ +three errors found diff --git a/test/files/neg/abstract-inaccessible.flags b/test/files/neg/abstract-inaccessible.flags new file mode 100644 index 0000000000..6c1dd108ae --- /dev/null +++ b/test/files/neg/abstract-inaccessible.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Xlint
\ No newline at end of file diff --git a/test/files/neg/abstract-inaccessible.scala b/test/files/neg/abstract-inaccessible.scala new file mode 100644 index 0000000000..3c80f30522 --- /dev/null +++ b/test/files/neg/abstract-inaccessible.scala @@ -0,0 +1,9 @@ +package foo { + private[foo] trait Bippy { } + + trait YourTrait { + def implementMe(f: Int => (String, Bippy)): Unit + def overrideMe[T <: Bippy](x: T): T = x + def overrideMeAlso(x: Map[Int, Set[Bippy]]) = 5 + } +} diff --git a/test/files/neg/bug278.check b/test/files/neg/bug278.check index ad0a97371e..b1041b7895 100644 --- a/test/files/neg/bug278.check +++ b/test/files/neg/bug278.check @@ -1,5 +1,5 @@ bug278.scala:5: error: overloaded method value a with alternatives: - => (C.this.A) => Unit <and> + => C.this.A => Unit <and> => () => Unit does not take type parameters a[A] diff --git a/test/files/neg/bug4419.check b/test/files/neg/bug4419.check new file mode 100644 index 0000000000..488be9a591 --- /dev/null +++ b/test/files/neg/bug4419.check @@ -0,0 +1,4 @@ +bug4419.scala:2: error: forward reference extends over definition of value b + { val b = a; val a = 1 } + ^ +one error found diff --git a/test/files/neg/bug4419.scala b/test/files/neg/bug4419.scala new file mode 100644 index 0000000000..38a34be489 --- /dev/null +++ b/test/files/neg/bug4419.scala @@ -0,0 +1,3 @@ +class A { + { val b = a; val a = 1 } +}
\ No newline at end of file diff --git a/test/files/neg/bug4533.check b/test/files/neg/bug4533.check deleted file mode 100644 index b405619831..0000000000 --- a/test/files/neg/bug4533.check +++ /dev/null @@ -1,4 +0,0 @@ -bug4533.scala:6: error: trait GenSetLike in package collection cannot be accessed in package collection - def statusByAlarms(alarms: GenSetLike[FooAlarm]) = println("hello") - ^ -one error found diff --git a/test/files/neg/bug4533.scala b/test/files/neg/bug4533.scala deleted file mode 100644 index 425c958328..0000000000 --- a/test/files/neg/bug4533.scala +++ /dev/null @@ -1,8 +0,0 @@ -package demo - -import scala.collection._ - -class CrashDemo { - def statusByAlarms(alarms: GenSetLike[FooAlarm]) = println("hello") -} -class FooAlarm { } diff --git a/test/files/neg/bug4584.check b/test/files/neg/bug4584.check new file mode 100644 index 0000000000..0008d9efa5 --- /dev/null +++ b/test/files/neg/bug4584.check @@ -0,0 +1,4 @@ +bug4584.scala:1: error: incomplete unicode escape +class A { val \u2 + ^ +one error found diff --git a/test/files/neg/bug4584.scala b/test/files/neg/bug4584.scala new file mode 100644 index 0000000000..b34aba91a2 --- /dev/null +++ b/test/files/neg/bug4584.scala @@ -0,0 +1 @@ +class A { val \u2
\ No newline at end of file diff --git a/test/files/neg/bug4727.check b/test/files/neg/bug4727.check new file mode 100644 index 0000000000..cac35b1548 --- /dev/null +++ b/test/files/neg/bug4727.check @@ -0,0 +1,11 @@ +bug4727.scala:5: error: type mismatch; + found : Null + required: Int +Note that implicit conversions are not applicable because they are ambiguous: + both method Integer2intNullConflict in class LowPriorityImplicits of type (x: Null)Int + and method Integer2int in object Predef of type (x: java.lang.Integer)Int + are possible conversion functions from Null to Int +Error occurred in an application involving default arguments. + new C[Int] + ^ +one error found diff --git a/test/files/neg/bug4727.scala b/test/files/neg/bug4727.scala new file mode 100644 index 0000000000..40c06713ca --- /dev/null +++ b/test/files/neg/bug4727.scala @@ -0,0 +1,7 @@ +class C[T](x : T = null) + +object Test { + def main(args: Array[String]): Unit = { + new C[Int] + } +} diff --git a/test/files/neg/bug588.check b/test/files/neg/bug588.check index 5f55c95619..8c01ac5b09 100644 --- a/test/files/neg/bug588.check +++ b/test/files/neg/bug588.check @@ -1,6 +1,6 @@ bug588.scala:3: error: double definition: -method visit:(f: (Int) => String)Boolean and -method visit:(f: (Int) => Unit)Boolean at line 2 +method visit:(f: Int => String)Boolean and +method visit:(f: Int => Unit)Boolean at line 2 have same type after erasure: (f: Function1)Boolean def visit(f: Int => String): Boolean ^ diff --git a/test/files/neg/bug752.check b/test/files/neg/bug752.check index dddab530e4..9262f38f01 100644 --- a/test/files/neg/bug752.check +++ b/test/files/neg/bug752.check @@ -1,6 +1,6 @@ bug752.scala:6: error: type mismatch; - found : (String) => Unit - required: (Int) => Unit + found : String => Unit + required: Int => Unit f(g _) ^ one error found diff --git a/test/files/neg/divergent-implicit.check b/test/files/neg/divergent-implicit.check index 07af8510d9..5f20df1b91 100644 --- a/test/files/neg/divergent-implicit.check +++ b/test/files/neg/divergent-implicit.check @@ -3,15 +3,15 @@ divergent-implicit.scala:4: error: type mismatch; required: String val x1: String = 1 ^ -divergent-implicit.scala:5: error: diverging implicit expansion for type (Int) => String +divergent-implicit.scala:5: error: diverging implicit expansion for type Int => String starting with method cast in object Test1 val x2: String = cast[Int, String](1) ^ -divergent-implicit.scala:14: error: diverging implicit expansion for type (Test2.Baz) => Test2.Bar +divergent-implicit.scala:14: error: diverging implicit expansion for type Test2.Baz => Test2.Bar starting with method baz2bar in object Test2 val x: Bar = new Foo ^ -divergent-implicit.scala:15: error: diverging implicit expansion for type (Test2.Foo) => Test2.Bar +divergent-implicit.scala:15: error: diverging implicit expansion for type Test2.Foo => Test2.Bar starting with method foo2bar in object Test2 val y: Bar = new Baz ^ diff --git a/test/files/neg/nullary-override.check b/test/files/neg/nullary-override.check new file mode 100644 index 0000000000..6b2ded2d4a --- /dev/null +++ b/test/files/neg/nullary-override.check @@ -0,0 +1,4 @@ +nullary-override.scala:2: error: non-nullary method overrides nullary method +class B extends A { override def x(): Int = 4 } + ^ +one error found diff --git a/test/files/neg/nullary-override.flags b/test/files/neg/nullary-override.flags new file mode 100644 index 0000000000..6c1dd108ae --- /dev/null +++ b/test/files/neg/nullary-override.flags @@ -0,0 +1 @@ +-Xfatal-warnings -Xlint
\ No newline at end of file diff --git a/test/files/neg/nullary-override.scala b/test/files/neg/nullary-override.scala new file mode 100644 index 0000000000..3eb4784a0c --- /dev/null +++ b/test/files/neg/nullary-override.scala @@ -0,0 +1,3 @@ +class A { def x: Int = 3 } +class B extends A { override def x(): Int = 4 } + diff --git a/test/files/neg/t0003.check b/test/files/neg/t0003.check index fb5bb5671d..1913dde9dd 100644 --- a/test/files/neg/t0003.check +++ b/test/files/neg/t0003.check @@ -1,6 +1,6 @@ t0003.scala:2: error: type mismatch; - found : (A) => (B) => B - required: (A) => B + found : A => B => B + required: A => B def foo[A, B, C](l: List[A], f: A => B=>B, g: B=>B=>C): List[C] = l map (g compose f) ^ one error found diff --git a/test/files/neg/t0015.check b/test/files/neg/t0015.check index eb25fc46c8..43adc22f72 100644 --- a/test/files/neg/t0015.check +++ b/test/files/neg/t0015.check @@ -1,6 +1,6 @@ t0015.scala:5: error: type mismatch; found : () => Nothing - required: (Nothing) => ? + required: Nothing => ? Nil.map(f _) ^ one error found diff --git a/test/files/neg/t2179.check b/test/files/neg/t2179.check deleted file mode 100644 index aa94fabe1f..0000000000 --- a/test/files/neg/t2179.check +++ /dev/null @@ -1,9 +0,0 @@ -t2179.scala:2: error: inferred type arguments [scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}}] do not conform to method reduceLeft's type parameter bounds [B >: List[Double]] - (Nil:List[List[Double]]).reduceLeft((_: Any, _: Any) => Nil.indices.map(_ => 0d)) - ^ -t2179.scala:2: error: type mismatch; - found : (Any, Any) => scala.collection.immutable.IndexedSeq[Double] - required: (scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}}, List[Double]) => scala.collection.immutable.Seq[Double]{def companion: scala.collection.generic.GenericCompanion[scala.collection.immutable.Seq[Any]]; protected def thisCollection: Seq[Double]{def companion: scala.collection.generic.GenericCompanion[Seq[Any]]}} - (Nil:List[List[Double]]).reduceLeft((_: Any, _: Any) => Nil.indices.map(_ => 0d)) - ^ -two errors found diff --git a/test/files/neg/t2641.check b/test/files/neg/t2641.check index f19a901859..771624e8d9 100644 --- a/test/files/neg/t2641.check +++ b/test/files/neg/t2641.check @@ -19,7 +19,17 @@ t2641.scala:25: error: something is wrong (wrong class file?): trait ManagedSeq t2641.scala:27: error: something is wrong (wrong class file?): trait ManagedSeq with type parameters [A,Coll] gets applied to arguments [], phase = namer trait Sliced extends Transformed[A] with super.Sliced { ^ +t2641.scala:27: error: illegal inheritance; superclass Any + is not a subclass of the superclass ManagedSeqStrict + of the mixin trait Transformed + trait Sliced extends Transformed[A] with super.Sliced { + ^ +t2641.scala:27: error: illegal inheritance; superclass Any + is not a subclass of the superclass Object + of the mixin trait Sliced + trait Sliced extends Transformed[A] with super.Sliced { + ^ t2641.scala:28: error: value managedIterator is not a member of ManagedSeq override def managedIterator = self.managedIterator slice (from, until) ^ -7 errors found +9 errors found diff --git a/test/files/neg/t3507.check b/test/files/neg/t3507.check index ab38280c1f..8e538e4a8b 100644 --- a/test/files/neg/t3507.check +++ b/test/files/neg/t3507.check @@ -1,4 +1,4 @@ -t3507.scala:13: error: No Manifest available for object _1.b.c. +t3507.scala:13: error: No Manifest available for _1.b.c.type. mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier ^ one error found diff --git a/test/files/neg/t3774.check b/test/files/neg/t3774.check deleted file mode 100644 index cce2d7076c..0000000000 --- a/test/files/neg/t3774.check +++ /dev/null @@ -1,7 +0,0 @@ -t3774.scala:4: error: overloaded method value ++ with alternatives: - [B1 >: List[Int]](xs: scala.collection.GenTraversableOnce[((Int, Int), B1)])scala.collection.immutable.Map[(Int, Int),B1] <and> - [B >: ((Int, Int), List[Int]), That](that: scala.collection.GenTraversableOnce[B])(implicit bf: scala.collection.generic.CanBuildFrom[scala.collection.immutable.Map[(Int, Int),List[Int]],B,That])That - cannot be applied to (scala.collection.immutable.IndexedSeq[((Int, Int), scala.collection.immutable.Range.Inclusive)]) - Map[(Int,Int),List[Int]]() ++ (for(x <- 0 to 1 ; y <- 0 to 1) yield {(x,y)-> (0 to 1)}) - ^ -one error found diff --git a/test/files/neg/unit2anyref.check b/test/files/neg/unit2anyref.check index 2616fd35f9..10fe1861f5 100644 --- a/test/files/neg/unit2anyref.check +++ b/test/files/neg/unit2anyref.check @@ -1,8 +1,8 @@ unit2anyref.scala:2: error: type mismatch; found : Unit required: AnyRef -Note: primitive types are not implicitly converted to AnyRef. -You can safely force boxing by casting x.asInstanceOf[AnyRef]. +Note: Unit is not implicitly converted to AnyRef. You can safely +pattern match `x: AnyRef` or cast `x.asInstanceOf[AnyRef]` to do so. val x: AnyRef = () // this should not succeed. ^ one error found diff --git a/test/files/neg/variances.check b/test/files/neg/variances.check index d395e45e4e..4eaab56cef 100644 --- a/test/files/neg/variances.check +++ b/test/files/neg/variances.check @@ -7,7 +7,7 @@ variances.scala:14: error: covariant type A occurs in contravariant position in variances.scala:16: error: covariant type A occurs in invariant position in supertype test.C[A] with ScalaObject of object Baz object Baz extends C[A] ^ -variances.scala:63: error: covariant type A occurs in contravariant position in type => test.Covariant.T[A]{val m: (A) => A} of value x +variances.scala:63: error: covariant type A occurs in contravariant position in type => test.Covariant.T[A]{val m: A => A} of value x val x: T[A] { ^ variances.scala:79: error: covariant type T occurs in contravariant position in type => test.TestAlias.B[C.this.A] of method foo diff --git a/test/files/pos/bug1439.flags b/test/files/pos/bug1439.flags new file mode 100644 index 0000000000..779916d58f --- /dev/null +++ b/test/files/pos/bug1439.flags @@ -0,0 +1 @@ +-unchecked -Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t1439.scala b/test/files/pos/bug1439.scala index ae1fdd10b5..68a7332b2a 100644 --- a/test/files/pos/t1439.scala +++ b/test/files/pos/bug1439.scala @@ -1,4 +1,5 @@ -class View[C[A]] {} +// no unchecked warnings +class View[C[A]] { } object Test { null match { diff --git a/test/files/pos/bug2094.scala b/test/files/pos/bug2094.scala new file mode 100644 index 0000000000..ff142117b2 --- /dev/null +++ b/test/files/pos/bug2094.scala @@ -0,0 +1,31 @@ +object Test extends App { + // compiles: + Map[Int, Value]( + 0 -> KnownType(classOf[Object]), + 1 -> UnknownValue()) + + // does not compile: + Map( + 0 -> KnownType(classOf[Object]), + 1 -> UnknownValue()) + + // Experiment.scala:10: error: type mismatch; + // found : (Int, KnownType) + // required: (Int, Product with Value{def getType: Option[java.lang.Class[_$$2]]}) where type _$$2 + // 0 -> KnownType(classOf[Object]), + // ^ + // one error found +} +sealed trait Value { + def getType: Option[Class[_]] +} + +case class UnknownValue() extends Value { + def getType = None + // compiles if changed to: + // def getType: Option[Class[_]] = None +} + +case class KnownType(typ: Class[_]) extends Value { + def getType = Some(typ) +}
\ No newline at end of file diff --git a/test/files/pos/bug3048.scala b/test/files/pos/bug3048.scala new file mode 100644 index 0000000000..dc056ecba2 --- /dev/null +++ b/test/files/pos/bug3048.scala @@ -0,0 +1,8 @@ +class B +object C extends B + +class F[T <: B](cons: => T) +class F2[T <: B](cons: => T) extends F(cons) + +object D extends F2(C) // works +object E extends F2(new B {}) diff --git a/test/files/pos/bug3343.scala b/test/files/pos/bug3343.scala new file mode 100644 index 0000000000..6c34cdff00 --- /dev/null +++ b/test/files/pos/bug3343.scala @@ -0,0 +1,15 @@ +import scala.collection.mutable.{ Builder, ListBuffer } + +object Test { + class Converter[T] + object SimpleIntConverter extends Converter[Int] + + class TraversableConverter[T, Coll[X] <: Traversable[X]](converter: Converter[T], builder: Builder[T, Coll[T]]) extends Converter[Coll[T]] { + def convert(x: T): List[T] = List(x) + } + val tc: Converter[List[Int]] = new TraversableConverter(SimpleIntConverter, new ListBuffer[Int]) + val tc2 = new TraversableConverter(SimpleIntConverter, new ListBuffer[Int]) + + def main(args: Array[String]): Unit = { + } +}
\ No newline at end of file diff --git a/test/files/pos/bug3528.scala b/test/files/pos/bug3528.scala new file mode 100644 index 0000000000..ff49b3e929 --- /dev/null +++ b/test/files/pos/bug3528.scala @@ -0,0 +1,8 @@ +class A { + // 3528 - not fixed + // def f1 = List(List(1), Stream(1)) + // 3528 comments + def f2 = List(Set(1,2,3), List(1,2,3)) + // 2322 + def f3 = List(null: Range, null: List[Int]) +} diff --git a/test/files/pos/bug4018.scala b/test/files/pos/bug4018.scala new file mode 100644 index 0000000000..2b265c5717 --- /dev/null +++ b/test/files/pos/bug4018.scala @@ -0,0 +1,15 @@ +trait M[V[_]] + +class Cls[V[_]](c: M[V]) + +object Cls{ + def apply[V[_]](c: M[V]): Cls[V] = new Cls[V](c) +} + +object test { + val c: M[Option] = new M[Option] {} + new Cls(c) // does not infer. + new Cls[Option](c) // okay + Cls(c) // okay +} + diff --git a/test/files/pos/bug4237.scala b/test/files/pos/bug4237.scala new file mode 100644 index 0000000000..fcf6eb8bf1 --- /dev/null +++ b/test/files/pos/bug4237.scala @@ -0,0 +1,6 @@ +class A { + (new { def field = 0; def field_=(i: Int) = () }).field = 5 // compiles as expected + (new { def field(implicit i: Int) = 0; def field_=(i: Int) = () }).field = 5 // compiles even with implicit params on getter + (new { def field = 0; def field_=[T](i: Int) = () }).field = 5 // compiles with type param on setter + (new { def field[T] = 0; def field_=(i: Int) = () }).field = 5 // DOESN'T COMPILE +}
\ No newline at end of file diff --git a/test/files/pos/bug4501.scala b/test/files/pos/bug4501.scala new file mode 100644 index 0000000000..40628f1a4b --- /dev/null +++ b/test/files/pos/bug4501.scala @@ -0,0 +1,14 @@ +// After lub modification +import scala.collection.mutable.ListBuffer + +class A { + def foo[T](a:T, b:T):T = a + def f1 = foo(ListBuffer(), List()) + def f2 = foo(ListBuffer(), ListBuffer()) + def f3 = foo(List(), List()) + + // scalap + // def f1 : scala.collection.Seq[scala.Nothing] = { /* compiled code */ } + // def f2 : scala.collection.mutable.ListBuffer[scala.Nothing] = { /* compiled code */ } + // def f3 : scala.collection.immutable.List[scala.Nothing] = { /* compiled code */ } +}
\ No newline at end of file diff --git a/test/files/pos/bug4553.scala b/test/files/pos/bug4553.scala new file mode 100755 index 0000000000..4eefe57b2b --- /dev/null +++ b/test/files/pos/bug4553.scala @@ -0,0 +1,11 @@ +trait VectorLike[+T, +V[A] <: Vector[A]] { + def +[S, VResult[S] >: V[S]](v: VResult[S]) +} + +trait Vector[+T] extends VectorLike[T, Vector] +trait ImmutableVector[T] extends Vector[T] with VectorLike[T, ImmutableVector] +trait MutableVector[T] extends Vector[T] with VectorLike[T, MutableVector] + +object Test { + def f = (null: MutableVector[Int]) + (null: ImmutableVector[Int]) +} diff --git a/test/files/pos/bug4731.scala b/test/files/pos/bug4731.scala new file mode 100644 index 0000000000..d457543c1f --- /dev/null +++ b/test/files/pos/bug4731.scala @@ -0,0 +1,14 @@ +import java.util.Comparator + +trait Trait1[T] { def foo(arg: Comparator[T]): Unit } + +trait Trait2[T] extends Trait1[T] { def foo(arg: Comparator[String]): Int = 0 } + +class Class1 extends Trait2[String] { } + +object Test { + def main(args: Array[String]): Unit = { + val c = new Class1 + c.foo(Ordering[String]) + } +} diff --git a/test/files/pos/hk-infer.scala b/test/files/pos/hk-infer.scala new file mode 100644 index 0000000000..30e3476404 --- /dev/null +++ b/test/files/pos/hk-infer.scala @@ -0,0 +1,37 @@ +object Basis { + final case class X[T](t: T) + val x = Seq(X(32)) + val y = Seq(X(true)) + val x1 = Seq(X("asdf")) + val x2 = Seq(X('d')) +} +import Basis._ + +object DoesWork { + // Doesn'tWork + // def f1 = x ++ y ++ x1 ++ x2 + + def f2 = List(x, y, x1, x2).flatten +} + +// Testing the not giving of explicit Booper[M] arguments. +object ShouldWorkHK { + class Booper[M[_]](xs: Seq[M[_]]) extends collection.generic.SeqForwarder[M[_]] { + def underlying = xs + def BOOP(ys: Seq[M[_]]) = new Booper(xs ++ ys) + } + implicit def mkBoop[M[_]](xs: Seq[M[_]]) = new Booper(xs) + + def f1 = x BOOP y BOOP x1 BOOP x2 +} + +object DoesWorkHK { + class Booper[M[_]](xs: Seq[M[_]]) extends collection.generic.SeqForwarder[M[_]] { + def underlying = xs + def BOOP(ys: Seq[M[_]]) = new Booper[M](xs ++ ys) + } + implicit def mkBoop[M[_]](xs: Seq[M[_]]) = new Booper[M](xs) + + def f1 = x BOOP y BOOP x1 BOOP x2 +} + diff --git a/test/files/neg/t2179.scala b/test/files/pos/t2179.scala index 89e22b6e2a..89e22b6e2a 100755 --- a/test/files/neg/t2179.scala +++ b/test/files/pos/t2179.scala diff --git a/test/files/neg/t3774.scala b/test/files/pos/t3774.scala index 2869925b01..2869925b01 100644 --- a/test/files/neg/t3774.scala +++ b/test/files/pos/t3774.scala diff --git a/test/files/pos/t4547.scala b/test/files/pos/t4547.scala new file mode 100644 index 0000000000..01f229bbf6 --- /dev/null +++ b/test/files/pos/t4547.scala @@ -0,0 +1,4 @@ +object Main { + def g: BigInt = 5 + BigInt(4) // since we're looking for an implicit that converts an int into something that has a + method that takes a BigInt, BigInt should be in the implicit scope + def g2 = 5 + BigInt(4) +}
\ No newline at end of file diff --git a/test/files/pos/t4593.scala b/test/files/pos/t4593.scala new file mode 100644 index 0000000000..250f68216a --- /dev/null +++ b/test/files/pos/t4593.scala @@ -0,0 +1,20 @@ +// ticket #4593 +trait A { + + class B + case object D extends B + + class C { + + var x: B = D + + def y = synchronized { + x match { + case D => {} + } + } + + } + +} + diff --git a/test/files/pos/t4692.scala b/test/files/pos/t4692.scala new file mode 100644 index 0000000000..409daf2257 --- /dev/null +++ b/test/files/pos/t4692.scala @@ -0,0 +1,27 @@ +class TypeAliasVsImplicitTest { + + class For[m[_], a](x: m[a]) { + def map[b](y: a => b): m[b] = throw new Error + } + implicit def toFor[m[_], a](x: m[a]): For[m, a] = new For[m, a](x) + + trait MyList[A] + + def foo(xs: MyList[Int]) = xs.map(x => x) // compiles fine. + + type MyListOfInt = MyList[Int] + def bar(xs: MyListOfInt) = xs.map(x => x) // doesn't compile: value map is not a member of TypeAliasVsImplicitTest.this.MyListOfInt +} + +// minimal case -- the bug was in type constructor inference where `xs.type` needed to be widened *and* dealiased +// in 2.8.1 implicit conversion search started with a widened type, so that combo never came up +// object Test { +// class For[m[_], a](x: m[a]) +// def toFor[m[_], a](x: m[a]): For[m, a] = new For[m, a](x) +// +// trait MyList[A] +// type MyListOfInt = MyList[Int] +// +// val xs: MyListOfInt = error("") +// toFor(xs : xs.type) +// }
\ No newline at end of file diff --git a/test/files/pos/widen-existential.scala b/test/files/pos/widen-existential.scala new file mode 100644 index 0000000000..d7fa3cc1d8 --- /dev/null +++ b/test/files/pos/widen-existential.scala @@ -0,0 +1,7 @@ +class A { + { val x = classOf[List[_]] } + def f = { + val g = classOf[List[_]] + List(g, g) + } +}
\ No newline at end of file diff --git a/test/files/run/TestFlatMap.scala b/test/files/run/TestFlatMap.scala new file mode 100644 index 0000000000..e6fb696aa2 --- /dev/null +++ b/test/files/run/TestFlatMap.scala @@ -0,0 +1,29 @@ +import scala.collection.parallel.{ ParMap => PMap } +import scala.collection.parallel.mutable.{ ParHashSet => PMHashSet, ParHashMap => PMHashMap, ParArray } +import scala.util.Random +import scala.collection.parallel.CompositeThrowable + +object Test { + + def main(args: Array[String]) { + val N = 1500 + val M = 1500 + var unmatchedLeft = new PMHashSet[Int] + var unmatchedRight = new PMHashSet[Int] + Range(0, N).foreach{ x => unmatchedLeft += x} + Range(0, M).foreach{ x => unmatchedRight += x} + + try { + val matches = unmatchedLeft.flatMap{ lind: Int => + val dists = unmatchedRight.seq.map{ rind: Int => + val dist = Random.nextInt + (rind, dist) + } + dists + } + } catch { + case c: CompositeThrowable => for (t <- c.throwables) println("\n%s\n%s".format(t, t.getStackTrace.mkString("\n"))) + } + } + +} diff --git a/test/files/run/bug2308a.check b/test/files/run/bug2308a.check new file mode 100644 index 0000000000..888240c702 --- /dev/null +++ b/test/files/run/bug2308a.check @@ -0,0 +1 @@ +interface Test$T diff --git a/test/files/run/bug2308a.scala b/test/files/run/bug2308a.scala new file mode 100644 index 0000000000..fff158c772 --- /dev/null +++ b/test/files/run/bug2308a.scala @@ -0,0 +1,7 @@ +object Test { + trait T[M[_]] + + def f1 = classOf[T[X] forSome { type X[_] } ] + + def main(args: Array[String]): Unit = println(f1) +} diff --git a/test/files/run/bug4110.check b/test/files/run/bug4110.check new file mode 100644 index 0000000000..8b005989de --- /dev/null +++ b/test/files/run/bug4110.check @@ -0,0 +1,2 @@ +Object with Test$A with Test$B +Object with Test$A with Test$B diff --git a/test/files/run/bug4110.scala b/test/files/run/bug4110.scala new file mode 100644 index 0000000000..a42646ce52 --- /dev/null +++ b/test/files/run/bug4110.scala @@ -0,0 +1,11 @@ +object Test extends App { + def inferredType[T : Manifest](v : T) = println(manifest[T]) + + trait A + trait B + + inferredType(new A with B) + + val name = new A with B + inferredType(name) +}
\ No newline at end of file diff --git a/test/files/run/bug4570.check b/test/files/run/bug4570.check new file mode 100644 index 0000000000..257cc5642c --- /dev/null +++ b/test/files/run/bug4570.check @@ -0,0 +1 @@ +foo diff --git a/test/files/run/bug4570.scala b/test/files/run/bug4570.scala new file mode 100644 index 0000000000..5e1a20c52d --- /dev/null +++ b/test/files/run/bug4570.scala @@ -0,0 +1,8 @@ +object Test extends Enumeration { + val foo = Value + def bar = withName("foo") + + def main(args: Array[String]): Unit = { + values foreach println + } +} diff --git a/test/files/run/bug4656.check b/test/files/run/bug4656.check new file mode 100644 index 0000000000..15a62794a9 --- /dev/null +++ b/test/files/run/bug4656.check @@ -0,0 +1 @@ +List(1, 2, 3) diff --git a/test/files/run/bug4656.scala b/test/files/run/bug4656.scala new file mode 100644 index 0000000000..4f3d189c8f --- /dev/null +++ b/test/files/run/bug4656.scala @@ -0,0 +1,13 @@ +object Test { + def f = { + val buf = new collection.mutable.ListBuffer[Int] + buf ++= List(1, 2, 3) + val l = buf.toList + buf prependToList List(4, 5, 6) + l + } + + def main(args: Array[String]): Unit = { + println(f) + } +} diff --git a/test/files/run/bug4660.scala b/test/files/run/bug4660.scala new file mode 100644 index 0000000000..e57bb4bf25 --- /dev/null +++ b/test/files/run/bug4660.scala @@ -0,0 +1,11 @@ +object Test { + def main(args: Array[String]): Unit = { + val traversable = 1 to 20 map (_.toString) + def normalize(m: Map[Char, Traversable[String]]) = m.map { case (k,v) => (k, v.toList) } + + val groupedFromView = (traversable view).groupBy(_(0)) + val groupedFromStrict = traversable.groupBy(_(0)) + + assert(normalize(groupedFromView) == normalize(groupedFromStrict)) + } +} diff --git a/test/files/run/bug4697.check b/test/files/run/bug4697.check new file mode 100644 index 0000000000..b9d569380c --- /dev/null +++ b/test/files/run/bug4697.check @@ -0,0 +1 @@ +50005000 diff --git a/test/files/run/bug4697.scala b/test/files/run/bug4697.scala new file mode 100644 index 0000000000..95592172e0 --- /dev/null +++ b/test/files/run/bug4697.scala @@ -0,0 +1,8 @@ +object Test { + var st = Stream(0) + for (i <- 1 to 10000) st = i +: st + + def main(args: Array[String]): Unit = { + println(st.take(10000).sum) + } +} diff --git a/test/files/run/constrained-types.check b/test/files/run/constrained-types.check index 6919eca9bc..66580f063a 100644 --- a/test/files/run/constrained-types.check +++ b/test/files/run/constrained-types.check @@ -100,7 +100,7 @@ scala> def m = { val y : String @Annot(x) = x y } // x should not escape the local scope with a narrow type -m: String @Annot("three") +m: java.lang.String @Annot(x) forSome { val x: java.lang.String } scala> diff --git a/test/files/run/getClassTest.check b/test/files/run/getClassTest.check new file mode 100644 index 0000000000..94e86c3889 --- /dev/null +++ b/test/files/run/getClassTest.check @@ -0,0 +1,18 @@ +f1: java.lang.Class<?> +f2: java.lang.Class<?> +f3: java.lang.Class<java.lang.Object> +f4: java.lang.Class<? extends java.lang.Integer> +f5: java.lang.Class<?> +f0: T +f1: class java.lang.Object +f2: class java.lang.Object +f3: class AnyRefs$A +f4: class AnyRefs$B +f5: class java.lang.Object +f6: class java.lang.Object +f7: class AnyRefs$A +f8: class AnyRefs$B +f1: java.lang.Class<? extends MoreAnyRefs$A> +f2: java.lang.Class<? extends MoreAnyRefs$B> +f3: java.lang.Class<?> +f4: java.lang.Class<? extends MoreAnyRefs$A> diff --git a/test/files/run/getClassTest.scala b/test/files/run/getClassTest.scala new file mode 100644 index 0000000000..951cc8d931 --- /dev/null +++ b/test/files/run/getClassTest.scala @@ -0,0 +1,66 @@ +class AnyVals { + def f1 = (5: Any).getClass + def f2 = (5: AnyVal).getClass + def f3 = 5.getClass + def f4 = (5: java.lang.Integer).getClass + def f5 = (5.asInstanceOf[AnyRef]).getClass + + // scalap says: + // + // def f1 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } + // def f2 : java.lang.Class[?0] forSome {type ?0} = { /* compiled code */ } + // def f3 : java.lang.Class[scala.Int] = { /* compiled code */ } + // def f4 : java.lang.Class[?0] forSome {type ?0 <: java.lang.Integer} = { /* compiled code */ } + // def f5 : java.lang.Class[?0] forSome {type ?0 <: scala.AnyRef} = { /* compiled code */ } + // + // java generic signature says: + // + // f1: java.lang.Class<?> + // f2: java.lang.Class<?> + // f3: java.lang.Class<java.lang.Object> + // f4: java.lang.Class<? extends java.lang.Integer> + // f5: java.lang.Class<?> +} + +class AnyRefs { + class A + class B extends A + + def f1 = (new B: Any).getClass().newInstance() + def f2 = (new B: AnyRef).getClass().newInstance() + def f3 = (new B: A).getClass().newInstance() + def f4 = (new B: B).getClass().newInstance() + + def f0[T >: B] = (new B: T).getClass().newInstance() + + def f5 = f0[Any] + def f6 = f0[AnyRef] + def f7 = f0[A] + def f8 = f0[B] +} + +class MoreAnyRefs { + trait A + trait B + + // don't leak anon/refinements + def f1 = (new A with B { }).getClass() + def f2 = (new B with A { }).getClass() + def f3 = (new { def bippy() = 5 }).getClass() + def f4 = (new A { def bippy() = 5 }).getClass() +} + +object Test { + def returnTypes[T: Manifest] = ( + manifest[T].erasure.getMethods.toList + filter (_.getName startsWith "f") + sortBy (_.getName) + map (m => m.getName + ": " + m.getGenericReturnType.toString) + ) + + def main(args: Array[String]): Unit = { + returnTypes[AnyVals] foreach println + returnTypes[AnyRefs] foreach println + returnTypes[MoreAnyRefs] foreach println + } +} diff --git a/test/files/run/null-and-intersect.check b/test/files/run/null-and-intersect.check new file mode 100644 index 0000000000..81890cfeff --- /dev/null +++ b/test/files/run/null-and-intersect.check @@ -0,0 +1,9 @@ +1 +2 +3 +4 +1 +2 +1 +2 +2 diff --git a/test/files/run/null-and-intersect.scala b/test/files/run/null-and-intersect.scala new file mode 100644 index 0000000000..7266dabe6d --- /dev/null +++ b/test/files/run/null-and-intersect.scala @@ -0,0 +1,34 @@ +object Test { + trait Immortal + class Bippy extends Immutable with Immortal + class Boppy extends Immutable + + def f[T](x: Traversable[T]) = x match { + case _: Map[_, _] => 3 + case _: Seq[_] => 2 + case _: Iterable[_] => 1 + case _ => 4 + } + def g(x: Bippy) = x match { + case _: Immutable with Immortal => 1 + case _ => 2 + } + def h(x: Immutable) = x match { + case _: Immortal => 1 + case _ => 2 + } + + def main(args: Array[String]): Unit = { + println(f(Set(1))) + println(f(Seq(1))) + println(f(Map(1 -> 2))) + println(f(null)) + + println(g(new Bippy)) + println(g(null)) + + println(h(new Bippy)) + println(h(new Boppy)) + println(h(null)) + } +} diff --git a/test/files/run/view-headoption.check b/test/files/run/view-headoption.check new file mode 100644 index 0000000000..5c98b54b46 --- /dev/null +++ b/test/files/run/view-headoption.check @@ -0,0 +1,28 @@ +fail +success +f1: Some(5) +fail +success +f2: 5 +fail +success +fail +fail +success +fail +fail +fail +success +f3: Some(5) +fail +success +fail +success +fail +fail +success +fail +fail +fail +success +f4: 5 diff --git a/test/files/run/view-headoption.scala b/test/files/run/view-headoption.scala new file mode 100644 index 0000000000..659c7e6b82 --- /dev/null +++ b/test/files/run/view-headoption.scala @@ -0,0 +1,18 @@ +object Test { + val failer = () => { println("fail") ; None } + val succeeder = () => { println("success") ; Some(5) } + val fs = List(failer, succeeder, failer, failer, succeeder, failer, failer, failer, succeeder) + + def f0 = fs.view flatMap (f => f()) + def f1 = f0.headOption + def f2 = f0.head + def f3 = f0.lastOption + def f4 = f0.last + + def main(args: Array[String]): Unit = { + println("f1: " + f1) + println("f2: " + f2) + println("f3: " + f3) + println("f4: " + f4) + } +} diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala index 6a0e83a47d..56295f204c 100644 --- a/test/files/scalacheck/range.scala +++ b/test/files/scalacheck/range.scala @@ -130,6 +130,13 @@ abstract class RangeTest(kind: String) extends Properties("Range "+kind) { (t.size == (0 max x min r.size) && t.start == r.start && t.step == r.step) :| str(r)+" / "+str(t)+": "+x } + property("init") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r => + (r.size == 0) || { + val t = r.init + (t.size + 1 == r.size) && (t.isEmpty || t.head == r.head) + } + } + property("takeWhile") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) => val t = (if (r.step > 0) r takeWhile (_ <= x) else r takeWhile(_ >= x)) if (r.size == 0) { diff --git a/test/files/specialized/fft.check b/test/files/specialized/fft.check index 69a3a61f36..845729084d 100644 --- a/test/files/specialized/fft.check +++ b/test/files/specialized/fft.check @@ -1,4 +1,4 @@ Processing 65536 items Boxed doubles: 0 Boxed ints: 2 -Boxed longs: 1310921 +Boxed longs: 1245366 diff --git a/test/files/pos/no-widen-locals.scala b/test/pending/pos/no-widen-locals.scala index 32579404b2..ba568f64eb 100644 --- a/test/files/pos/no-widen-locals.scala +++ b/test/pending/pos/no-widen-locals.scala @@ -1,3 +1,5 @@ +// Worked from r23262 until that was reverted somewhere +// around r25016. import annotation.switch object Test { diff --git a/test/pending/pos/those-kinds-are-high.scala b/test/pending/pos/those-kinds-are-high.scala new file mode 100644 index 0000000000..d3ee2bf308 --- /dev/null +++ b/test/pending/pos/those-kinds-are-high.scala @@ -0,0 +1,37 @@ +class A { + trait Container[+T] + trait Template[+CC[X] <: Container[X]] + + class C1[T] extends Template[C1] with Container[T] + class C2[T] extends Template[C2] with Container[T] + + /** Target expression: + * List(new C1[String], new C2[String]) + */ + + // Here's what would ideally be inferred. + // + // scala> :type List[Template[Container] with Container[String]](new C1[String], new C2[String]) + // List[Template[Container] with Container[java.lang.String]] + // + // Here's what it does infer. + // + // scala> :type List(new C1[String], new C2[String]) + // <console>:8: error: type mismatch; + // found : C1[String] + // required: Container[String] with Template[Container[Any] with Template[Container[Any] with Template[Any] with ScalaObject] with ScalaObject] with ScalaObject + // List(new C1[String], new C2[String]) + // ^ + // + // Simplified, the inferred type is: + // + // List[Container[String] with Template[Container[Any] with Template[Container[Any] with Template[Any]]] + // + + /** Working version explicitly typed. + */ + def fExplicit = List[Template[Container] with Container[String]](new C1[String], new C2[String]) + + // nope + // def fFail = List(new C1[String], new C2[String]) +} diff --git a/test/scaladoc/scala/IndexScriptTest.scala b/test/scaladoc/scala/IndexScriptTest.scala new file mode 100644 index 0000000000..991491c376 --- /dev/null +++ b/test/scaladoc/scala/IndexScriptTest.scala @@ -0,0 +1,52 @@ +import org.scalacheck._ +import org.scalacheck.Prop._ + +import scala.tools.nsc.doc +import scala.tools.nsc.doc.html.page.IndexScript +import java.net.URLClassLoader + +object Test extends Properties("IndexScript") { + + def getClasspath = { + val loader = Thread.currentThread.getContextClassLoader + val paths = loader.asInstanceOf[URLClassLoader].getURLs + val morepaths = loader.getParent.asInstanceOf[URLClassLoader].getURLs + (paths ++ morepaths).map(_.getPath).mkString(java.io.File.pathSeparator) + } + + val docFactory = { + val settings = new doc.Settings({Console.err.println(_)}) + settings.classpath.value = getClasspath + val reporter = new scala.tools.nsc.reporters.ConsoleReporter(settings) + new doc.DocFactory(reporter, settings) + } + + val indexModelFactory = doc.model.IndexModelFactory + + def createIndexScript(path: String) = + docFactory.makeUniverse(List(path)) match { + case Some(universe) => { + val index = new IndexScript(universe, + indexModelFactory.makeIndex(universe)) + Some(index) + } + case _ => + None + } + + property("allPackages") = { + createIndexScript("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match { + case Some(index) => + index.allPackages.map(_.toString) == List( + "scala", + "scala.tools", + "scala.tools.nsc", + "scala.tools.nsc.doc", + "scala.tools.nsc.doc.html", + "scala.tools.nsc.doc.html.page" + ) + case None => + false + } + } +} diff --git a/test/scaladoc/scala/IndexTest.scala b/test/scaladoc/scala/IndexTest.scala index 5e3d02e045..7679bab0c6 100644 --- a/test/scaladoc/scala/IndexTest.scala +++ b/test/scaladoc/scala/IndexTest.scala @@ -79,24 +79,4 @@ object Test extends Properties("Index") { case None => false } } - - property("allPackages") = { - createIndex("src/compiler/scala/tools/nsc/doc/html/page/Index.scala") match { - - case Some(index) => - index.allPackages.map(_.toString) == List( - "scala", - "scala.tools", - "scala.tools.nsc", - "scala.tools.nsc.doc", - "scala.tools.nsc.doc.html", - "scala.tools.nsc.doc.html.page" - ) - - case None => - false - - } - } - } |