diff --git a/tests/pending/neg/i1846.scala b/tests/pending/neg/i1846.scala new file mode 100644 index 000000000000..4e047a56cfdc --- /dev/null +++ b/tests/pending/neg/i1846.scala @@ -0,0 +1,5 @@ +object Bug { + final val x = 42 + val y = x + x match {case y.toString => 42 case y => 42} +} diff --git a/tests/pending/neg/i1905.scala b/tests/pending/neg/i1905.scala new file mode 100644 index 000000000000..f681ae9d35e3 --- /dev/null +++ b/tests/pending/neg/i1905.scala @@ -0,0 +1,21 @@ +class Arr[T](val underlying: scala.Array[T]) extends AnyVal { + def foo = underlying +} + +abstract class SeqMonoTransforms[+A, +Repr] { + protected[this] def fromIterableWithSameElemType(): Repr + def getFIWSET: Repr = fromIterableWithSameElemType +} + +class ArrOps[A](val xs: Arr[A]) extends SeqMonoTransforms[A, Arr[A]] { + def fromIterableWithSameElemType(): Arr[A] = xs +} + +object Test { + def main(args: Array[String]) = { + val arr = new Arr(Array(1, 2, 3)) + val t = new ArrOps(arr) + val t2 = t.getFIWSET + val x = arr.foo + } +} diff --git a/tests/pending/neg/i2104.scala b/tests/pending/neg/i2104.scala new file mode 100644 index 000000000000..b228bf532853 --- /dev/null +++ b/tests/pending/neg/i2104.scala @@ -0,0 +1,18 @@ +case class Pair[A, B](_1: A, _2: B) + +trait Cons[+H, +T] + +object Cons { + def apply[H, T](h: H, t: T): Cons[H, T] = ??? + def unapply[H, T](t: Cons[H, T]): Option[Pair[H, T]] = ??? +} + +object Test { + def main(args: Array[String]): Unit = { + Cons(Option(1), None) match { + case Cons(Some(i), None) => + i: Int // error: found: Any(i), requires: Int + assert(i == 1) + } + } +} diff --git a/tests/pending/neg/match.scala b/tests/pending/neg/match.scala new file mode 100644 index 000000000000..a3cfb6749ad6 --- /dev/null +++ b/tests/pending/neg/match.scala @@ -0,0 +1,33 @@ +object Test { + + class Seq[T] + class List[T] extends Seq[T] { def head: T = ??? } + + val ss: Seq[Int] = ??? + ss match { + case ss: List[int] => + val x = ss.head + val y: Int = x + } +} +object Test1 { + + class Seq[T] + class List[T] extends Seq[T] { def head: T = ??? } + + val ss: Seq[Int] = ??? + ss match { + case ss: List[Int] => + println(ss) + } +} +object Test2 { + + trait A + trait B + val x: A & B = ??? + + (x: A) match { + case x: B => + } +} diff --git a/tests/pending/pos/TypeIndexing.scala b/tests/pending/pos/TypeIndexing.scala new file mode 100644 index 000000000000..1fa985d8f724 --- /dev/null +++ b/tests/pending/pos/TypeIndexing.scala @@ -0,0 +1,18 @@ +// works in neither scalac nor dotty, but maybe could be made to work? + trait A { + type T + val t : T + } + + object A { + def unapply(arg: A): Option[arg.T] = Some(arg.t) + } + +object Test { + def use(a : A) = a match { + case b @ A(t) ⇒ + val s: b.T = t // type mismatch. + // found t.type (with underlying type .T) + // required: a.T + } +} diff --git a/tests/pending/pos/i1793.scala b/tests/pending/pos/i1793.scala new file mode 100644 index 000000000000..fed8a6165699 --- /dev/null +++ b/tests/pending/pos/i1793.scala @@ -0,0 +1,7 @@ +object Test { + import scala.ref.WeakReference + def unapply[T <: AnyRef](wr: WeakReference[T]): Option[T] = { + val x = wr.underlying.get + if (x != null) Some(x) else None + } +} diff --git a/tests/pending/pos/i1960.scala b/tests/pending/pos/i1960.scala new file mode 100644 index 000000000000..a3d441d17022 --- /dev/null +++ b/tests/pending/pos/i1960.scala @@ -0,0 +1,8 @@ +case class CC2[A, B](_1: A, _2: B) + +object Test { + def main(args: Array[String]): Unit = { + val CC2(_, CC2(a, _)) = CC2(0, CC2(1, 2)) + assert(a == 1) + } +} diff --git a/tests/pending/pos/i2032.scala b/tests/pending/pos/i2032.scala new file mode 100644 index 000000000000..50d9fbbcebde --- /dev/null +++ b/tests/pending/pos/i2032.scala @@ -0,0 +1,2 @@ +class foo(annotation: Any) // annotation.StaticAnnotation +@foo(new AnyRef {}) trait A diff --git a/tests/pending/pos/i2071.scala b/tests/pending/pos/i2071.scala new file mode 100644 index 000000000000..f60d4fc6e6da --- /dev/null +++ b/tests/pending/pos/i2071.scala @@ -0,0 +1,7 @@ +object Test { + type PF[A, B] = PartialFunction[A, B] + + val f: PF[Int, String] = { + case i => "bar" + } +} diff --git a/tests/pending/pos/match.scala b/tests/pending/pos/match.scala new file mode 100644 index 000000000000..d1ca3bdfc51c --- /dev/null +++ b/tests/pending/pos/match.scala @@ -0,0 +1,7 @@ +object Test { + + val ss: Seq[Int] = ??? + ss match { + case ss: List[Int] => ??? + } +} diff --git a/tests/pending/pos/namedTypeParams.scala b/tests/pending/pos/namedTypeParams.scala new file mode 100644 index 000000000000..0717d8475a6d --- /dev/null +++ b/tests/pending/pos/namedTypeParams.scala @@ -0,0 +1,9 @@ +object Test { + + def f[X, Y](x: X, y: Y): Int = ??? + + f[Int, String](1, "") + f[X = Int, Y = String](1, "") + f[X = Int](1, "") + f[Y = String](1, "") +} diff --git a/tests/pending/pos/t9844.scala b/tests/pending/pos/t9844.scala new file mode 100644 index 000000000000..b67e6d391a63 --- /dev/null +++ b/tests/pending/pos/t9844.scala @@ -0,0 +1,2 @@ +trait X[T <: X[T]] { self: T => } +object Y extends X[Y.type] diff --git a/tests/pending/run/i2072.scala b/tests/pending/run/i2072.scala new file mode 100644 index 000000000000..0e89cfffeaa3 --- /dev/null +++ b/tests/pending/run/i2072.scala @@ -0,0 +1,21 @@ +trait T { lazy val x: String = "foo" } +trait U { def x: Any } +abstract class AC extends T with U // { def x: Any } + +abstract class B { def x: Any } +class C extends B { def x: String = "abc" } + +package p2 { +trait T1 { def f: Any } +trait T2 extends T1 { def f: Number = ??? } +trait T3 extends T1 { override def f: Integer = ??? } +class C extends T2 with T3 +} + +package p3 { + + trait A { def f: Any } + trait B extends A { def f: String } + class C extends B { def f = "abc" } + +} diff --git a/tests/pending/run/nestedEq.scala b/tests/pending/run/nestedEq.scala new file mode 100644 index 000000000000..07613d1313c1 --- /dev/null +++ b/tests/pending/run/nestedEq.scala @@ -0,0 +1,43 @@ + class Outer { + + case class Inner() + case class Inner2() + + val inner: Inner = new Inner + val inner2 = new Inner2 + + def checkInstance(o: Outer) = + o.inner.isInstanceOf[this.Inner] + + def checkPattern1(i: Any) = + i match { + case _: Inner => true + case _ => false + } + + def checkPattern2(i: Any) = + i match { + case Inner() => true + case _ => false + } + + def checkEquals(o: Outer) = + o.inner == inner + + } + + object Test { + + def main(args: Array[String]) = { + val o1 = new Outer + val o2 = new Outer + println(o1.inner.hashCode) + println(o2.inner.hashCode) + println(o2.inner2.hashCode) + assert(o1.checkInstance(o2)) + assert(!o1.checkPattern1(o2.inner)) + assert(!o1.checkPattern2(o2.inner)) + assert(!o1.checkEquals(o2)) + } + + } diff --git a/tests/pos/i2081.scala b/tests/pos/i2081.scala new file mode 100644 index 000000000000..92aba9eed9b8 --- /dev/null +++ b/tests/pos/i2081.scala @@ -0,0 +1,11 @@ +trait Foo { + // This should not generate a $init method. + // Currently this needs to be verified by manual inspection of the bytecode. + def meth(x: Int): Int +} +trait Bar extends Foo +trait Bam + +class C extends Foo with Bar { + def meth(x: Int) = x +} diff --git a/tests/pos/i2278.scala b/tests/pos/i2278.scala new file mode 100644 index 000000000000..0e4b7feb0c9e --- /dev/null +++ b/tests/pos/i2278.scala @@ -0,0 +1,12 @@ +object Fluent { + trait Foo[C[_]] { + def meth1[T]() : C[T] + } + trait CC[T] + + type Context[Alg[x[_]] <: Foo[x], E] = implicit Alg[CC] => CC[E] + + def meth1[T]() : Context[Foo, T] = { + implicitly[Foo[CC]].meth1() + } +}