summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/package-ob-case.check4
-rw-r--r--test/files/neg/t5675.check2
-rw-r--r--test/files/neg/t5675.flags1
-rw-r--r--test/files/neg/t5675.scala7
-rw-r--r--test/files/neg/t5954.check14
-rw-r--r--test/files/neg/t5954.flags1
-rw-r--r--test/files/neg/t5954.scala2
-rw-r--r--test/files/neg/t6539/Macro_1.scala2
-rw-r--r--test/files/neg/t6539/Test_2.scala6
-rw-r--r--test/files/neg/t6666.check21
-rw-r--r--test/files/neg/t6666.scala29
-rw-r--r--test/files/neg/t6666b.check7
-rw-r--r--test/files/neg/t6666b.scala27
-rw-r--r--test/files/neg/t6666c.check10
-rw-r--r--test/files/neg/t6666c.scala8
-rw-r--r--test/files/neg/t6666d.check4
-rw-r--r--test/files/neg/t6666d.scala18
-rw-r--r--test/files/neg/t6666e.check4
-rw-r--r--test/files/neg/t6666e.scala9
19 files changed, 133 insertions, 43 deletions
diff --git a/test/files/neg/package-ob-case.check b/test/files/neg/package-ob-case.check
index 9031ad13e7..063a120db1 100644
--- a/test/files/neg/package-ob-case.check
+++ b/test/files/neg/package-ob-case.check
@@ -2,8 +2,6 @@ package-ob-case.scala:3: warning: it is not recommended to define classes/object
If possible, define class X in package foo instead.
case class X(z: Int) { }
^
-package-ob-case.scala:3: error: implementation restriction: package object foo cannot contain case class X. Instead, class X should be placed directly in package foo.
- case class X(z: Int) { }
- ^
+error: No warnings can be incurred under -Xfatal-warnings.
one warning found
one error found
diff --git a/test/files/neg/t5675.check b/test/files/neg/t5675.check
new file mode 100644
index 0000000000..da608a2b78
--- /dev/null
+++ b/test/files/neg/t5675.check
@@ -0,0 +1,2 @@
+error: there were 1 feature warning(s); re-run with -feature for details
+one error found
diff --git a/test/files/neg/t5675.flags b/test/files/neg/t5675.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/neg/t5675.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t5675.scala b/test/files/neg/t5675.scala
new file mode 100644
index 0000000000..238ed0fcae
--- /dev/null
+++ b/test/files/neg/t5675.scala
@@ -0,0 +1,7 @@
+class PostFix {
+ val list = List(1, 2, 3)
+ def main(args: Array[String]) {
+ val a = list filter (2 !=)
+ val b = list filter (2 != _)
+ }
+}
diff --git a/test/files/neg/t5954.check b/test/files/neg/t5954.check
index 3ca47cd430..3950d14e4e 100644
--- a/test/files/neg/t5954.check
+++ b/test/files/neg/t5954.check
@@ -1,16 +1,18 @@
-t5954.scala:36: error: implementation restriction: package object A cannot contain case class D. Instead, class D should be placed directly in package A.
+t5954.scala:36: warning: class D should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954.
case class D()
^
-t5954.scala:35: error: implementation restriction: package object A cannot contain companion object C. Instead, object C should be placed directly in package A.
+t5954.scala:35: warning: object C should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954.
object C
^
-t5954.scala:34: error: implementation restriction: package object A cannot contain companion trait C. Instead, trait C should be placed directly in package A.
+t5954.scala:34: warning: trait C should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954.
trait C
^
-t5954.scala:33: error: implementation restriction: package object A cannot contain companion object B. Instead, object B should be placed directly in package A.
+t5954.scala:33: warning: object B should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954.
object B
^
-t5954.scala:32: error: implementation restriction: package object A cannot contain companion class B. Instead, class B should be placed directly in package A.
+t5954.scala:32: warning: class B should be placed directly in package A instead of package object A. Under some circumstances companion objects and case classes in package objects can fail to recompile. See https://issues.scala-lang.org/browse/SI-5954.
class B
^
-5 errors found
+error: No warnings can be incurred under -Xfatal-warnings.
+5 warnings found
+one error found
diff --git a/test/files/neg/t5954.flags b/test/files/neg/t5954.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/t5954.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/t5954.scala b/test/files/neg/t5954.scala
index 9e6f5392c7..3ccb5ed3ff 100644
--- a/test/files/neg/t5954.scala
+++ b/test/files/neg/t5954.scala
@@ -1,4 +1,4 @@
-// if you ever think you've fixed the underlying reason for the implementation restrictions
+// if you ever think you've fixed the underlying reason for the warning
// imposed by SI-5954, then here's a test that should pass with two "succes"es
//
//import scala.tools.partest._
diff --git a/test/files/neg/t6539/Macro_1.scala b/test/files/neg/t6539/Macro_1.scala
index ed52776d95..4f7d289e2e 100644
--- a/test/files/neg/t6539/Macro_1.scala
+++ b/test/files/neg/t6539/Macro_1.scala
@@ -5,6 +5,6 @@ object M {
def m(a: Any, b: Any): Any = macro mImpl
def mImpl(c: Context)(a: c.Expr[Any], b: c.Expr[Any]) = a
- @reflect.macros.compileTimeOnly("cto may only be used as an argument to " + "m")
+ @reflect.internal.annotations.compileTimeOnly("cto may only be used as an argument to " + "m")
def cto = 0
}
diff --git a/test/files/neg/t6539/Test_2.scala b/test/files/neg/t6539/Test_2.scala
index 5a602879ec..26f4504222 100644
--- a/test/files/neg/t6539/Test_2.scala
+++ b/test/files/neg/t6539/Test_2.scala
@@ -3,4 +3,10 @@ object Test {
M.m(M.cto, ()) // error
M.m((), M.cto) // okay
M.cto // error
+
+ locally {
+ val expr = scala.reflect.runtime.universe.reify(2)
+ val splice = expr.splice
+ val value = expr.value
+ }
}
diff --git a/test/files/neg/t6666.check b/test/files/neg/t6666.check
index d0378173ea..6337d4c7d9 100644
--- a/test/files/neg/t6666.check
+++ b/test/files/neg/t6666.check
@@ -16,25 +16,22 @@ t6666.scala:54: error: Implementation restriction: access of value x$7 in class
t6666.scala:58: error: Implementation restriction: access of method x$8 in class C3 from anonymous class 9, would require illegal premature access to the unconstructed `this` of class C3
F.hof(() => x)
^
-t6666.scala:62: error: Implementation restriction: access of method x$9 in class C4 from object Nested$5, would require illegal premature access to the unconstructed `this` of class C4
+t6666.scala:62: error: Implementation restriction: access of method x$9 in class C4 from object Nested$4, would require illegal premature access to the unconstructed `this` of class C4
object Nested { def xx = x}
^
-t6666.scala:68: error: Implementation restriction: access of method x$10 in class C5 from object Nested$6, would require illegal premature access to the unconstructed `this` of class C5
- object Nested { def xx = x}
- ^
-t6666.scala:83: error: Implementation restriction: access of method x$12 in class C11 from anonymous class 12, would require illegal premature access to the unconstructed `this` of class C11
+t6666.scala:76: error: Implementation restriction: access of method x$11 in class C11 from anonymous class 12, would require illegal premature access to the unconstructed `this` of class C11
F.byname(x)
^
-t6666.scala:102: error: Implementation restriction: access of method x$13 in class C13 from anonymous class 13, would require illegal premature access to the unconstructed `this` of class C13
+t6666.scala:95: error: Implementation restriction: access of method x$12 in class C13 from anonymous class 13, would require illegal premature access to the unconstructed `this` of class C13
F.hof(() => x)
^
-t6666.scala:111: error: Implementation restriction: access of method x$14 in class C14 from object Nested$7, would require illegal premature access to the unconstructed `this` of class C14
+t6666.scala:104: error: Implementation restriction: access of method x$13 in class C14 from object Nested$5, would require illegal premature access to the unconstructed `this` of class C14
object Nested { def xx = x}
^
-t6666.scala:122: error: Implementation restriction: access of method x$15 in class C15 from object Nested$8, would require illegal premature access to the unconstructed `this` of class C15
- object Nested { def xx = x}
- ^
-t6666.scala:131: error: Implementation restriction: access of method foo$1 in class COuter from class CInner$1, would require illegal premature access to the unconstructed `this` of class COuter
+t6666.scala:112: error: Implementation restriction: access of method foo$1 in class COuter from class CInner$1, would require illegal premature access to the unconstructed `this` of class COuter
class CInner extends C({foo})
^
-13 errors found
+t6666.scala:118: error: Implementation restriction: access of method x$14 in class CEarly from object Nested$6, would require illegal premature access to the unconstructed `this` of class CEarly
+ object Nested { def xx = x}
+ ^
+12 errors found
diff --git a/test/files/neg/t6666.scala b/test/files/neg/t6666.scala
index d37ffaf141..1919ea3ca9 100644
--- a/test/files/neg/t6666.scala
+++ b/test/files/neg/t6666.scala
@@ -62,13 +62,6 @@ class C4 extends C({
object Nested { def xx = x}
Nested.xx
})
-class C5 extends C({
- def x = "".toString
- val y = {
- object Nested { def xx = x}
- Nested.xx
- }
-})
// okay, for same reason as O6
class C6 extends C({
@@ -114,19 +107,15 @@ class C14(a: Any) {
}
}
-class C15(a: Any) {
- def this() = {
- this({
- def x = "".toString
- val y = {
- object Nested { def xx = x}
- Nested.xx
- }
- })
- }
-}
-
class COuter extends C({
def foo = 0
class CInner extends C({foo})
-}) \ No newline at end of file
+})
+
+
+class CEarly(a: Any) extends {
+ val early = {def x = "".toString
+ object Nested { def xx = x}
+ Nested.xx
+ }
+} with AnyRef \ No newline at end of file
diff --git a/test/files/neg/t6666b.check b/test/files/neg/t6666b.check
new file mode 100644
index 0000000000..c3ffc7cfa9
--- /dev/null
+++ b/test/files/neg/t6666b.check
@@ -0,0 +1,7 @@
+t6666b.scala:11: error: Implementation restriction: access of method x$1 in class C5 from object Nested$3, would require illegal premature access to the unconstructed `this` of class C5
+ object Nested { def xx = x}
+ ^
+t6666b.scala:22: error: Implementation restriction: access of method x$2 in class C15 from object Nested$4, would require illegal premature access to the unconstructed `this` of class C15
+ object Nested { def xx = x}
+ ^
+two errors found
diff --git a/test/files/neg/t6666b.scala b/test/files/neg/t6666b.scala
new file mode 100644
index 0000000000..205ded76e5
--- /dev/null
+++ b/test/files/neg/t6666b.scala
@@ -0,0 +1,27 @@
+class C(a: Any)
+object F {
+ def byname(a: => Any) = println(a)
+ def hof(a: () => Any) = println(a())
+}
+
+
+class C5 extends C({
+ def x = "".toString
+ val y = {
+ object Nested { def xx = x}
+ Nested.xx
+ }
+})
+
+
+class C15(a: Any) {
+ def this() = {
+ this({
+ def x = "".toString
+ val y = {
+ object Nested { def xx = x}
+ Nested.xx
+ }
+ })
+ }
+}
diff --git a/test/files/neg/t6666c.check b/test/files/neg/t6666c.check
new file mode 100644
index 0000000000..8fb9f4ba14
--- /dev/null
+++ b/test/files/neg/t6666c.check
@@ -0,0 +1,10 @@
+t6666c.scala:2: error: Implementation restriction: access of method x$1 in class D from object X$4, would require illegal premature access to the unconstructed `this` of class D
+class D extends C({def x = 0; object X { x }})
+ ^
+t6666c.scala:5: error: Implementation restriction: access of method x$2 in class D1 from object X$5, would require illegal premature access to the unconstructed `this` of class D1
+class D1 extends C1({def x = 0; () => {object X { x }}})
+ ^
+t6666c.scala:8: error: Implementation restriction: access of method x$3 from object X$6, would require illegal premature access to the unconstructed `this` of anonymous class 2
+class D2 extends C2({def x = 0; object X { x }})
+ ^
+three errors found
diff --git a/test/files/neg/t6666c.scala b/test/files/neg/t6666c.scala
new file mode 100644
index 0000000000..76cc358307
--- /dev/null
+++ b/test/files/neg/t6666c.scala
@@ -0,0 +1,8 @@
+class C(a: Any)
+class D extends C({def x = 0; object X { x }})
+
+class C1(a: () => Any)
+class D1 extends C1({def x = 0; () => {object X { x }}})
+
+class C2(a: => Any)
+class D2 extends C2({def x = 0; object X { x }})
diff --git a/test/files/neg/t6666d.check b/test/files/neg/t6666d.check
new file mode 100644
index 0000000000..b4785f0129
--- /dev/null
+++ b/test/files/neg/t6666d.check
@@ -0,0 +1,4 @@
+t6666d.scala:7: error: Implementation restriction: access of object TreeOrd$1 from object TreeOrd$2, would require illegal premature access to the unconstructed `this` of class Test
+ implicit object TreeOrd extends Ordering[K](){
+ ^
+one error found
diff --git a/test/files/neg/t6666d.scala b/test/files/neg/t6666d.scala
new file mode 100644
index 0000000000..49a688f91b
--- /dev/null
+++ b/test/files/neg/t6666d.scala
@@ -0,0 +1,18 @@
+
+import scala.collection.immutable.TreeMap
+import scala.math.Ordering
+
+class Test[K](param:TreeMap[K,Int]){
+ def this() = this({
+ implicit object TreeOrd extends Ordering[K](){
+ def compare(a: K, b: K) = {
+ -1
+ }
+ }
+ new TreeMap[K, Int]()
+ })
+}
+
+object Test extends App {
+ new Test()
+}
diff --git a/test/files/neg/t6666e.check b/test/files/neg/t6666e.check
new file mode 100644
index 0000000000..9fcc3ab718
--- /dev/null
+++ b/test/files/neg/t6666e.check
@@ -0,0 +1,4 @@
+t6666e.scala:8: error: Implementation restriction: anonymous class $anonfun requires premature access to class Crash.
+ this(Nil.collect{case x =>})
+ ^
+one error found
diff --git a/test/files/neg/t6666e.scala b/test/files/neg/t6666e.scala
new file mode 100644
index 0000000000..120a5878b2
--- /dev/null
+++ b/test/files/neg/t6666e.scala
@@ -0,0 +1,9 @@
+
+import scala.collection.immutable.TreeMap
+import scala.math.Ordering
+
+
+class Crash(a: Any) {
+ def this() =
+ this(Nil.collect{case x =>})
+}