aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/i1642.scala1
-rw-r--r--tests/neg/i1670.scala1
-rw-r--r--tests/neg/i1779.scala13
-rw-r--r--tests/neg/i705-inner-value-class2.scala2
-rw-r--r--tests/neg/implicitDefs.scala7
-rw-r--r--tests/neg/t3683-modified.scala20
6 files changed, 43 insertions, 1 deletions
diff --git a/tests/neg/i1642.scala b/tests/neg/i1642.scala
new file mode 100644
index 000000000..2f7644698
--- /dev/null
+++ b/tests/neg/i1642.scala
@@ -0,0 +1 @@
+class Test2(val valueVal: Test2) extends AnyVal // error: value class cannot wrap itself
diff --git a/tests/neg/i1670.scala b/tests/neg/i1670.scala
new file mode 100644
index 000000000..69c47eda7
--- /dev/null
+++ b/tests/neg/i1670.scala
@@ -0,0 +1 @@
+class A(a:Int, b:Int) extends AnyVal // error: value class needs to have exactly one val parameter
diff --git a/tests/neg/i1779.scala b/tests/neg/i1779.scala
new file mode 100644
index 000000000..92100fa06
--- /dev/null
+++ b/tests/neg/i1779.scala
@@ -0,0 +1,13 @@
+object Test {
+ implicit class Foo(sc: StringContext) {
+ object q {
+ def apply(arg: Any*): Int = 3
+ }
+ }
+
+ def f = {
+ val _parent = 3
+ q"val hello = $_parent"
+ q"class $_" // error // error
+ }
+}
diff --git a/tests/neg/i705-inner-value-class2.scala b/tests/neg/i705-inner-value-class2.scala
index a084da338..d59449b6b 100644
--- a/tests/neg/i705-inner-value-class2.scala
+++ b/tests/neg/i705-inner-value-class2.scala
@@ -1,5 +1,5 @@
class Foo {
- class B(val a: Int) extends AnyVal
+ class B(val a: Int) extends AnyVal // error: value class may not be a member of another class`
}
object Test {
diff --git a/tests/neg/implicitDefs.scala b/tests/neg/implicitDefs.scala
index 1489344c8..3bfe60434 100644
--- a/tests/neg/implicitDefs.scala
+++ b/tests/neg/implicitDefs.scala
@@ -8,4 +8,11 @@ object implicitDefs {
implicit val x = 2 // error: type of implicit definition needs to be given explicitly
implicit def y(x: Int) = 3 // error: result type of implicit definition needs to be given explicitly
implicit def z(a: x.type): String = "" // error: implicit conversion may not have a parameter of singleton type
+
+ def foo(implicit x: String) = 1
+
+ def bar() = {
+ implicit val x = foo // error: cyclic reference
+ x
+ }
}
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)
+ }
+ }
+}