aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/neg/t3683-modified.scala20
-rw-r--r--tests/pending/pos/i1535.scala9
-rw-r--r--tests/pending/pos/i1710.scala11
-rw-r--r--tests/pending/run/i1732.scala8
-rw-r--r--tests/pos/Monoid.scala61
-rw-r--r--tests/pos/i1704.scala4
-rw-r--r--tests/pos/i1777.scala9
7 files changed, 122 insertions, 0 deletions
diff --git a/tests/neg/t3683-modified.scala b/tests/neg/t3683-modified.scala
new file mode 100644
index 000000000..19b981e0a
--- /dev/null
+++ b/tests/neg/t3683-modified.scala
@@ -0,0 +1,20 @@
+sealed trait Foo
+sealed trait Bar extends Foo
+sealed trait W[T >: Bar <: Foo]
+case class X() extends W[Foo]
+case class XX() extends W[Bar]
+case class Y() extends W[Bar]
+case class Z[T >: T <: Foo]( // error: cyclic reference
+ z1: W[T]
+) extends W[T]
+
+object Main {
+ // should warn for not including XX()
+ def f1(w: W[Bar]): Int = {
+ w match {
+ // case XX() => 2
+ case Y() => 1
+ case Z(z) => f1(z)
+ }
+ }
+}
diff --git a/tests/pending/pos/i1535.scala b/tests/pending/pos/i1535.scala
new file mode 100644
index 000000000..a574ca706
--- /dev/null
+++ b/tests/pending/pos/i1535.scala
@@ -0,0 +1,9 @@
+object Example {
+ case class C[H, T](h: H, t: T)
+
+ type I = Int
+
+ val p
+ : C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,C[I,I]]]]]]]]]]]]]]]]]]]]]]]
+ = C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,C(1,1)))))))))))))))))))))))
+}
diff --git a/tests/pending/pos/i1710.scala b/tests/pending/pos/i1710.scala
new file mode 100644
index 000000000..703244ea9
--- /dev/null
+++ b/tests/pending/pos/i1710.scala
@@ -0,0 +1,11 @@
+object Hello extends App {
+
+ val (a: Int, b: Int) = (4, 5) // works
+ val (z, k): (4, 5) = (4, 5) // works
+
+ val cd: (4, 5) = (4, 5)
+ val c: 4 = cd._1
+ val d: 5 = cd._2
+ val (x: 4, y: 5) = (4, 5) // doesn't work
+
+}
diff --git a/tests/pending/run/i1732.scala b/tests/pending/run/i1732.scala
new file mode 100644
index 000000000..748c9c3e5
--- /dev/null
+++ b/tests/pending/run/i1732.scala
@@ -0,0 +1,8 @@
+object Test {
+ import scala.util.control.Breaks
+ def main(args: Array[String]): Unit = {
+ Breaks.breakable {
+ Breaks.break
+ }
+ }
+}
diff --git a/tests/pos/Monoid.scala b/tests/pos/Monoid.scala
new file mode 100644
index 000000000..f6004cdf3
--- /dev/null
+++ b/tests/pos/Monoid.scala
@@ -0,0 +1,61 @@
+package strawman.typeclasses
+
+trait SemiGroup[T] {
+ def append(x: T, y: T): T
+}
+object SemiGroup {
+ class Ops {
+ implicit class InfixAppend[T: SemiGroup](self: T) {
+ def |+| (other: T): T = implicitly[SemiGroup[T]].append(self, other)
+ }
+ }
+ object ops extends Ops
+}
+
+trait Monoid[T] extends SemiGroup[T] {
+ val id: T
+}
+object Monoid {
+ object ops extends SemiGroup.Ops
+}
+
+trait Ring[T] extends Monoid[T] {
+ val zero = id
+ val one: T
+ def product(x: T, y: T): T
+}
+object Ring {
+ class Ops extends SemiGroup.Ops {
+ implicit class InfixProduct[T: Ring](self: T) {
+ def |*| (other: T): T = implicitly[Ring[T]].product(self, other)
+ }
+ }
+ object ops extends Ops
+}
+
+
+
+object Test {
+ implicit object StringMonoid extends Monoid[String] {
+ def append(x: String, y: String): String = x ++ y
+ val id = ""
+ }
+
+ implicit object IntRing extends Ring[Int] {
+ def append(x: Int, y: Int) = x + y
+ val id = 0
+ val one = 1
+ def product(x: Int, y: Int) = x * y
+ }
+
+ import Monoid.ops._ // works in dotty, fails in scalac
+ import Ring.ops._
+ "abc" |+| "def"
+ "abc" |+| StringMonoid.id
+ StringMonoid.id |+| "abc"
+
+ 1 |+| 2
+ 3 |*| 3
+
+
+}
diff --git a/tests/pos/i1704.scala b/tests/pos/i1704.scala
new file mode 100644
index 000000000..94bc03c4d
--- /dev/null
+++ b/tests/pos/i1704.scala
@@ -0,0 +1,4 @@
+trait AnyRef {
+ val StringMatch = new AnyRef {}
+ trait Something { (AnyRef) match { case (StringMatch) => } }
+}
diff --git a/tests/pos/i1777.scala b/tests/pos/i1777.scala
new file mode 100644
index 000000000..381ff9139
--- /dev/null
+++ b/tests/pos/i1777.scala
@@ -0,0 +1,9 @@
+object Main extends App {
+ import scala.collection.immutable._
+ case class Foo(s: String)
+ {
+ implicit val orderingS: Ordering[String] = Ordering[String] // Crash
+ val tree = TreeMap.empty ++ (1 to 100).map { i => Foo(i.toString) -> i }
+ println(tree.getClass)
+ }
+}