aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/i1568.scala3
-rw-r--r--tests/neg/structural.scala11
-rw-r--r--tests/neg/valueclasses-impl-restrictions.scala19
-rw-r--r--tests/neg/zoo.scala14
4 files changed, 40 insertions, 7 deletions
diff --git a/tests/neg/i1568.scala b/tests/neg/i1568.scala
new file mode 100644
index 000000000..a260c530b
--- /dev/null
+++ b/tests/neg/i1568.scala
@@ -0,0 +1,3 @@
+object Test {
+ inline def foo(n: Int) = foo(n) // error: cyclic reference
+}
diff --git a/tests/neg/structural.scala b/tests/neg/structural.scala
new file mode 100644
index 000000000..aab52b2cb
--- /dev/null
+++ b/tests/neg/structural.scala
@@ -0,0 +1,11 @@
+object Test3 {
+ import scala.reflect.Selectable.reflectiveSelectable
+ def g(x: { type T ; def t: T ; def f(a: T): Boolean }) = x.f(x.t) // error: no ClassTag for x.T
+ g(new { type T = Int; def t = 4; def f(a:T) = true })
+ g(new { type T = Any; def t = 4; def f(a:T) = true })
+ val y: { type T = Int; def t = 4; def f(a:T) = true }
+ = new { type T = Int; def t = 4; def f(a:T) = true }
+
+ def h(x: { def f[T](a: T): Int }) = x.f[Int](4) // error: polymorphic refinement method ... no longer allowed
+
+}
diff --git a/tests/neg/valueclasses-impl-restrictions.scala b/tests/neg/valueclasses-impl-restrictions.scala
new file mode 100644
index 000000000..9f33b7e7c
--- /dev/null
+++ b/tests/neg/valueclasses-impl-restrictions.scala
@@ -0,0 +1,19 @@
+class X1(val s: String) extends AnyVal {
+ trait I2 { // error: value class may not define an inner class or trait
+ val q: String
+ def z = s + q
+ }
+}
+
+class X2(val s: String) extends AnyVal {
+ private[this] class I2(val q: String) // error: value class may not define an inner class or trait
+
+ def y(i: Int) = {
+ val i2 = new I2(i.toString)
+ i2.q + s
+ }
+}
+
+class X3(val s: String) extends AnyVal {
+ object I3 // error: value class may not define non-parameter field
+}
diff --git a/tests/neg/zoo.scala b/tests/neg/zoo.scala
index 19efcc1d7..1674548e8 100644
--- a/tests/neg/zoo.scala
+++ b/tests/neg/zoo.scala
@@ -7,19 +7,19 @@ type Grass = {
}
type Animal = {
type Food
- def eats(food: Food): Unit // error
- def gets: Food // error
+ def eats(food: Food): Unit
+ def gets: Food
}
type Cow = {
type IsMeat = Any
type Food <: Grass
- def eats(food: Grass): Unit // error
- def gets: Grass // error
+ def eats(food: Grass): Unit
+ def gets: Grass
}
type Lion = {
type Food = Meat
- def eats(food: Meat): Unit // error
- def gets: Meat // error
+ def eats(food: Meat): Unit
+ def gets: Meat
}
def newMeat: Meat = new {
type IsMeat = Any
@@ -40,5 +40,5 @@ def newLion: Lion = new {
}
val milka = newCow
val leo = newLion
-leo.eats(milka) // structural select not supported
+leo.eats(milka) // error: no projector found
}