summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSimon Ochsenreither <simon@ochsenreither.de>2013-12-10 20:11:07 +0100
committerSimon Ochsenreither <simon@ochsenreither.de>2014-01-09 00:43:14 +0100
commitc5567e2700dfe6c19d968c2285821ef4ab8a8e6c (patch)
tree6a120e3ec4d31224fd3f36956824b1a23944dee7 /test
parentada8d9156baad2d8a24c1a40e032eb4bc7154bac (diff)
downloadscala-c5567e2700dfe6c19d968c2285821ef4ab8a8e6c.tar.gz
scala-c5567e2700dfe6c19d968c2285821ef4ab8a8e6c.tar.bz2
scala-c5567e2700dfe6c19d968c2285821ef4ab8a8e6c.zip
SI-8035 Deprecate automatic () insertion in argument lists
This promotes the () insertion warning from -Ywarn-adapted-args to a deprecation warning. -Xfuture tunrs it into a compiler error. Auto tupling remains unchanged for now. The tests have been fixed the following way: - Warnings caused by general sloppiness (Try(), Future(), ...) have been fixed. - Warnings which raise interesting questions (x == (), ...) received an updated checkfile for now.
Diffstat (limited to 'test')
-rw-r--r--test/files/jvm/daemon-actor-termination.scala2
-rw-r--r--test/files/jvm/future-spec/FutureTests.scala9
-rw-r--r--test/files/jvm/interpreter.check2
-rw-r--r--test/files/jvm/interpreter.scala2
-rw-r--r--test/files/jvm/try-type-tests.scala264
-rw-r--r--test/files/neg/t4851.check8
-rw-r--r--test/files/neg/t4851.flags2
-rw-r--r--test/files/neg/t8035-deprecated.check21
-rw-r--r--test/files/neg/t8035-deprecated.flags1
-rw-r--r--test/files/neg/t8035-deprecated.scala10
-rw-r--r--test/files/neg/t8035-removed.check16
-rw-r--r--test/files/neg/t8035-removed.flags1
-rw-r--r--test/files/neg/t8035-removed.scala10
-rw-r--r--test/files/run/partialfun.scala2
-rw-r--r--test/files/run/t5629b.check2
-rw-r--r--test/files/run/t5629b.scala7
-rw-r--r--test/files/run/t576.check1
-rw-r--r--test/files/run/t6662/Test_2.scala2
-rw-r--r--test/files/run/t6863.check1
-rw-r--r--test/files/run/t6935.check1
-rw-r--r--test/files/run/t6935.scala18
21 files changed, 217 insertions, 165 deletions
diff --git a/test/files/jvm/daemon-actor-termination.scala b/test/files/jvm/daemon-actor-termination.scala
index 40acd8583e..9bac6340ba 100644
--- a/test/files/jvm/daemon-actor-termination.scala
+++ b/test/files/jvm/daemon-actor-termination.scala
@@ -11,7 +11,7 @@ object Test {
react {
case 'hello =>
println("MSG1")
- reply()
+ reply(())
react {
case 'bye =>
println("done")
diff --git a/test/files/jvm/future-spec/FutureTests.scala b/test/files/jvm/future-spec/FutureTests.scala
index cfdcc31ac5..a290af9cd3 100644
--- a/test/files/jvm/future-spec/FutureTests.scala
+++ b/test/files/jvm/future-spec/FutureTests.scala
@@ -1,6 +1,3 @@
-
-
-
import scala.concurrent._
import scala.concurrent.duration._
import scala.concurrent.duration.Duration.Inf
@@ -518,7 +515,7 @@ class FutureTests extends MinimalScalaTest {
}
"should not deadlock with nested await (ticket 1313)" in {
- val simple = Future() map {
+ val simple = Future(()) map {
_ =>
val unit = Future(())
val umap = unit map { _ => () }
@@ -527,7 +524,7 @@ class FutureTests extends MinimalScalaTest {
Await.ready(simple, Inf).isCompleted mustBe (true)
val l1, l2 = new TestLatch
- val complex = Future() map {
+ val complex = Future(()) map {
_ =>
blocking {
val nested = Future(())
@@ -549,5 +546,3 @@ class FutureTests extends MinimalScalaTest {
}
}
-
-
diff --git a/test/files/jvm/interpreter.check b/test/files/jvm/interpreter.check
index 6e5fada381..b55ecc10e6 100644
--- a/test/files/jvm/interpreter.check
+++ b/test/files/jvm/interpreter.check
@@ -58,7 +58,7 @@ t1513: Array[Null] = Array(null)
scala> // ambiguous toString problem from #547
-scala> val atom = new scala.xml.Atom()
+scala> val atom = new scala.xml.Atom(())
atom: scala.xml.Atom[Unit] = ()
scala> // overriding toString problem from #1404
diff --git a/test/files/jvm/interpreter.scala b/test/files/jvm/interpreter.scala
index bd1851053f..c68c064c31 100644
--- a/test/files/jvm/interpreter.scala
+++ b/test/files/jvm/interpreter.scala
@@ -25,7 +25,7 @@ println("hello")
// ticket #1513
val t1513 = Array(null)
// ambiguous toString problem from #547
-val atom = new scala.xml.Atom()
+val atom = new scala.xml.Atom(())
// overriding toString problem from #1404
class S(override val toString : String)
val fish = new S("fish")
diff --git a/test/files/jvm/try-type-tests.scala b/test/files/jvm/try-type-tests.scala
index e5e53ee737..962afbd30f 100644
--- a/test/files/jvm/try-type-tests.scala
+++ b/test/files/jvm/try-type-tests.scala
@@ -3,139 +3,139 @@ import scala.util.{Try, Success, Failure}
// tests the basic combinators on Try
trait TryStandard {
- def testForeachSuccess(): Unit = {
- val t = Success(1)
- var res = 0
- t.foreach(x => res = x * 10)
- assert(res == 10)
- }
-
- def testForeachFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- t.foreach(x => assert(false))
- }
-
- def testFlatMapSuccess(): Unit = {
- val t = Success(1)
- val n = t.flatMap(x => Try(x * 10))
- assert(n.get == 10)
- }
-
- def testFlatMapFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.flatMap{ x => assert(false); Try() }
- }
-
- def testMapSuccess(): Unit = {
- val t = Success(1)
- val n = t.map(x => x * 10)
- assert(n.get == 10)
- }
-
- def testMapFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.map(x => assert(false))
- }
-
- def testFilterSuccessTrue(): Unit = {
- val t = Success(1)
- val n = t.filter(x => x > 0)
- assert(n.get == 1)
- }
-
- def testFilterSuccessFalse(): Unit = {
- val t = Success(1)
- val n = t.filter(x => x < 0)
- n match {
- case Success(v) => assert(false)
- case Failure(e: NoSuchElementException) => assert(true)
+ def testForeachSuccess(): Unit = {
+ val t = Success(1)
+ var res = 0
+ t.foreach(x => res = x * 10)
+ assert(res == 10)
+ }
+
+ def testForeachFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ t.foreach(x => assert(false))
+ }
+
+ def testFlatMapSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.flatMap(x => Try(x * 10))
+ assert(n.get == 10)
+ }
+
+ def testFlatMapFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.flatMap{ x => assert(false); Try(()) }
+ }
+
+ def testMapSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.map(x => x * 10)
+ assert(n.get == 10)
+ }
+
+ def testMapFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.map(x => assert(false))
+ }
+
+ def testFilterSuccessTrue(): Unit = {
+ val t = Success(1)
+ val n = t.filter(x => x > 0)
+ assert(n.get == 1)
+ }
+
+ def testFilterSuccessFalse(): Unit = {
+ val t = Success(1)
+ val n = t.filter(x => x < 0)
+ n match {
+ case Success(v) => assert(false)
+ case Failure(e: NoSuchElementException) => assert(true)
case _ => assert(false)
- }
- }
-
- def testFilterFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.filter{ x => assert(false); true }
- }
-
- def testRescueSuccess(): Unit = {
- val t = Success(1)
- t.recoverWith{ case x => assert(false); Try() }
- }
-
- def testRescueFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.recoverWith{ case x => Try(1) }
- assert(n.get == 1)
- }
-
- def testRecoverSuccess(): Unit = {
- val t = Success(1)
- t.recover{ case x => assert(false); 99 }
- }
-
- def testRecoverFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.recover{ case x => 1 }
- assert(n.get == 1)
- }
-
- def testFlattenSuccess(): Unit = {
- val f = Failure(new Exception("foo"))
- val t = Success(f)
- assert(t.flatten == f)
- }
-
- def testFailedSuccess(): Unit = {
- val t = Success(1)
- val n = t.failed
- n match {
- case Failure(e: UnsupportedOperationException) => assert(true)
- case _ => assert(false)
- }
- }
-
- def testFailedFailure(): Unit = {
- val t = Failure(new Exception("foo"))
- val n = t.failed
- n match {
- case Success(e: Exception) => assert(true)
- case _ => assert(false)
- }
- }
-
- def testSuccessTransform(): Unit = {
- val s = Success(1)
- val succ = (x: Int) => Success(x * 10)
- val fail = (x: Throwable) => Success(0)
- assert(s.transform(succ, fail).get == 10)
- }
-
- def testFailureTransform(): Unit = {
- val f = Failure(new Exception("foo"))
- val succ = (x: Int) => Success(x * 10)
- val fail = (x: Throwable) => Success(0)
- assert(f.transform(succ, fail).get == 0)
- }
-
- testForeachSuccess()
- testForeachFailure()
- testFlatMapSuccess()
- testFlatMapFailure()
- testMapSuccess()
- testMapFailure()
- testFilterSuccessTrue()
- testFilterSuccessFalse()
- testFilterFailure()
- testRescueSuccess()
- testRescueFailure()
- testRecoverSuccess()
- testRecoverFailure()
- testFlattenSuccess()
- testFailedSuccess()
- testFailedFailure()
- testSuccessTransform()
- testFailureTransform()
+ }
+ }
+
+ def testFilterFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.filter{ x => assert(false); true }
+ }
+
+ def testRescueSuccess(): Unit = {
+ val t = Success(1)
+ t.recoverWith{ case x => assert(false); Try(()) }
+ }
+
+ def testRescueFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.recoverWith{ case x => Try(1) }
+ assert(n.get == 1)
+ }
+
+ def testRecoverSuccess(): Unit = {
+ val t = Success(1)
+ t.recover{ case x => assert(false); 99 }
+ }
+
+ def testRecoverFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.recover{ case x => 1 }
+ assert(n.get == 1)
+ }
+
+ def testFlattenSuccess(): Unit = {
+ val f = Failure(new Exception("foo"))
+ val t = Success(f)
+ assert(t.flatten == f)
+ }
+
+ def testFailedSuccess(): Unit = {
+ val t = Success(1)
+ val n = t.failed
+ n match {
+ case Failure(e: UnsupportedOperationException) => assert(true)
+ case _ => assert(false)
+ }
+ }
+
+ def testFailedFailure(): Unit = {
+ val t = Failure(new Exception("foo"))
+ val n = t.failed
+ n match {
+ case Success(e: Exception) => assert(true)
+ case _ => assert(false)
+ }
+ }
+
+ def testSuccessTransform(): Unit = {
+ val s = Success(1)
+ val succ = (x: Int) => Success(x * 10)
+ val fail = (x: Throwable) => Success(0)
+ assert(s.transform(succ, fail).get == 10)
+ }
+
+ def testFailureTransform(): Unit = {
+ val f = Failure(new Exception("foo"))
+ val succ = (x: Int) => Success(x * 10)
+ val fail = (x: Throwable) => Success(0)
+ assert(f.transform(succ, fail).get == 0)
+ }
+
+ testForeachSuccess()
+ testForeachFailure()
+ testFlatMapSuccess()
+ testFlatMapFailure()
+ testMapSuccess()
+ testMapFailure()
+ testFilterSuccessTrue()
+ testFilterSuccessFalse()
+ testFilterFailure()
+ testRescueSuccess()
+ testRescueFailure()
+ testRecoverSuccess()
+ testRecoverFailure()
+ testFlattenSuccess()
+ testFailedSuccess()
+ testFailedFailure()
+ testSuccessTransform()
+ testFailureTransform()
}
object Test
diff --git a/test/files/neg/t4851.check b/test/files/neg/t4851.check
index 4f2919807e..132dd91b50 100644
--- a/test/files/neg/t4851.check
+++ b/test/files/neg/t4851.check
@@ -1,10 +1,10 @@
-S.scala:2: warning: Adapting argument list by inserting (): leaky (Object-receiving) target makes this especially dangerous.
+S.scala:2: warning: Adaptation of argument list by inserting () has been deprecated: leaky (Object-receiving) target makes this especially dangerous.
signature: J(x: Any): J
given arguments: <none>
after adaptation: new J((): Unit)
val x1 = new J
^
-S.scala:3: warning: Adapting argument list by inserting (): leaky (Object-receiving) target makes this especially dangerous.
+S.scala:3: warning: Adaptation of argument list by inserting () has been deprecated: leaky (Object-receiving) target makes this especially dangerous.
signature: J(x: Any): J
given arguments: <none>
after adaptation: new J((): Unit)
@@ -28,13 +28,13 @@ S.scala:7: warning: Adapting argument list by creating a 3-tuple: this may not b
after adaptation: new Some((1, 2, 3): (Int, Int, Int))
val y2 = new Some(1, 2, 3)
^
-S.scala:9: warning: Adapting argument list by inserting (): this is unlikely to be what you want.
+S.scala:9: warning: Adaptation of argument list by inserting () has been deprecated: this is unlikely to be what you want.
signature: J2[T](x: T): J2[T]
given arguments: <none>
after adaptation: new J2((): Unit)
val z1 = new J2
^
-S.scala:10: warning: Adapting argument list by inserting (): this is unlikely to be what you want.
+S.scala:10: warning: Adaptation of argument list by inserting () has been deprecated: this is unlikely to be what you want.
signature: J2[T](x: T): J2[T]
given arguments: <none>
after adaptation: new J2((): Unit)
diff --git a/test/files/neg/t4851.flags b/test/files/neg/t4851.flags
index 0545cb8b84..ca0d0a0ba3 100644
--- a/test/files/neg/t4851.flags
+++ b/test/files/neg/t4851.flags
@@ -1 +1 @@
--Ywarn-adapted-args -Xfatal-warnings
+-Ywarn-adapted-args -Xfatal-warnings -deprecation
diff --git a/test/files/neg/t8035-deprecated.check b/test/files/neg/t8035-deprecated.check
new file mode 100644
index 0000000000..01f27e5310
--- /dev/null
+++ b/test/files/neg/t8035-deprecated.check
@@ -0,0 +1,21 @@
+t8035-deprecated.scala:2: warning: Adaptation of argument list by inserting () has been deprecated: this is unlikely to be what you want.
+ signature: GenSetLike.apply(elem: A): Boolean
+ given arguments: <none>
+ after adaptation: GenSetLike((): Unit)
+ List(1,2,3).toSet()
+ ^
+t8035-deprecated.scala:5: warning: Adaptation of argument list by inserting () has been deprecated: this is unlikely to be what you want.
+ signature: A(x: T): Foo.A[T]
+ given arguments: <none>
+ after adaptation: new A((): Unit)
+ new A
+ ^
+t8035-deprecated.scala:9: warning: Adaptation of argument list by inserting () has been deprecated: leaky (Object-receiving) target makes this especially dangerous.
+ signature: Format.format(x$1: Any): String
+ given arguments: <none>
+ after adaptation: Format.format((): Unit)
+ sdf.format()
+ ^
+error: No warnings can be incurred under -Xfatal-warnings.
+three warnings found
+one error found
diff --git a/test/files/neg/t8035-deprecated.flags b/test/files/neg/t8035-deprecated.flags
new file mode 100644
index 0000000000..c6bfaf1f64
--- /dev/null
+++ b/test/files/neg/t8035-deprecated.flags
@@ -0,0 +1 @@
+-deprecation -Xfatal-warnings
diff --git a/test/files/neg/t8035-deprecated.scala b/test/files/neg/t8035-deprecated.scala
new file mode 100644
index 0000000000..6423157530
--- /dev/null
+++ b/test/files/neg/t8035-deprecated.scala
@@ -0,0 +1,10 @@
+object Foo {
+ List(1,2,3).toSet()
+
+ class A[T](val x: T)
+ new A
+
+ import java.text.SimpleDateFormat
+ val sdf = new SimpleDateFormat("yyyyMMdd-HH0000")
+ sdf.format()
+}
diff --git a/test/files/neg/t8035-removed.check b/test/files/neg/t8035-removed.check
new file mode 100644
index 0000000000..e24a0b4e63
--- /dev/null
+++ b/test/files/neg/t8035-removed.check
@@ -0,0 +1,16 @@
+t8035-removed.scala:2: error: Adaptation of argument list by inserting () has been removed.
+ signature: GenSetLike.apply(elem: A): Boolean
+ given arguments: <none>
+ List(1,2,3).toSet()
+ ^
+t8035-removed.scala:5: error: Adaptation of argument list by inserting () has been removed.
+ signature: A(x: T): Foo.A[T]
+ given arguments: <none>
+ new A
+ ^
+t8035-removed.scala:9: error: Adaptation of argument list by inserting () has been removed.
+ signature: Format.format(x$1: Any): String
+ given arguments: <none>
+ sdf.format()
+ ^
+three errors found
diff --git a/test/files/neg/t8035-removed.flags b/test/files/neg/t8035-removed.flags
new file mode 100644
index 0000000000..29f4ede37a
--- /dev/null
+++ b/test/files/neg/t8035-removed.flags
@@ -0,0 +1 @@
+-Xfuture
diff --git a/test/files/neg/t8035-removed.scala b/test/files/neg/t8035-removed.scala
new file mode 100644
index 0000000000..6423157530
--- /dev/null
+++ b/test/files/neg/t8035-removed.scala
@@ -0,0 +1,10 @@
+object Foo {
+ List(1,2,3).toSet()
+
+ class A[T](val x: T)
+ new A
+
+ import java.text.SimpleDateFormat
+ val sdf = new SimpleDateFormat("yyyyMMdd-HH0000")
+ sdf.format()
+}
diff --git a/test/files/run/partialfun.scala b/test/files/run/partialfun.scala
index f3c53b94ae..71c7d3e61c 100644
--- a/test/files/run/partialfun.scala
+++ b/test/files/run/partialfun.scala
@@ -76,7 +76,7 @@ object Test {
}
val chained = pf0 orElse pf1 orElse pf2
- chained()
+ chained(())
}
def main(args: Array[String]): Unit = {
diff --git a/test/files/run/t5629b.check b/test/files/run/t5629b.check
index 1bc0248c3d..e0f25f0b05 100644
--- a/test/files/run/t5629b.check
+++ b/test/files/run/t5629b.check
@@ -2,7 +2,7 @@
MySmartPF.apply entered...
newPF.applyOrElse entered...
default
-scala.MatchError: () (of class scala.runtime.BoxedUnit)
+scala.MatchError: 1 (of class java.lang.Integer)
=== pf(42):
MySmartPF.apply entered...
newPF.applyOrElse entered...
diff --git a/test/files/run/t5629b.scala b/test/files/run/t5629b.scala
index 9ff29c8d89..5d402201ae 100644
--- a/test/files/run/t5629b.scala
+++ b/test/files/run/t5629b.scala
@@ -1,8 +1,3 @@
-
-
-
-
-
object Test extends App {
trait MyPF[@specialized(Int) -A] extends (A => Unit) {
@@ -16,7 +11,7 @@ object Test extends App {
trait MySmartPF[@specialized(Int) -A] extends MyPF[A] {
def apply(x: A): Unit = {
println("MySmartPF.apply entered...")
- applyOrElse(x, { _: Any => throw new MatchError })
+ applyOrElse(x, { default: Any => throw new MatchError(default) })
}
}
diff --git a/test/files/run/t576.check b/test/files/run/t576.check
index 8a1218a102..6458d5d743 100644
--- a/test/files/run/t576.check
+++ b/test/files/run/t576.check
@@ -1,3 +1,4 @@
+warning: there were 1 deprecation warning(s); re-run with -deprecation for details
1
2
3
diff --git a/test/files/run/t6662/Test_2.scala b/test/files/run/t6662/Test_2.scala
index 03a80b655a..82ac54cb46 100644
--- a/test/files/run/t6662/Test_2.scala
+++ b/test/files/run/t6662/Test_2.scala
@@ -2,7 +2,7 @@
object Test {
def main(args: Array[String]) {
- val s = Demo id ()
+ val s = Demo id (())
println(s)
}
}
diff --git a/test/files/run/t6863.check b/test/files/run/t6863.check
index 030cb8b265..fea22b582f 100644
--- a/test/files/run/t6863.check
+++ b/test/files/run/t6863.check
@@ -10,3 +10,4 @@ t6863.scala:46: warning: comparing values of types Unit and Unit using `==' will
t6863.scala:59: warning: comparing values of types Unit and Unit using `==' will always yield true
assert({ () => x }.apply == ())
^
+warning: there were 4 deprecation warning(s); re-run with -deprecation for details
diff --git a/test/files/run/t6935.check b/test/files/run/t6935.check
new file mode 100644
index 0000000000..844ca54682
--- /dev/null
+++ b/test/files/run/t6935.check
@@ -0,0 +1 @@
+warning: there were 1 deprecation warning(s); re-run with -deprecation for details
diff --git a/test/files/run/t6935.scala b/test/files/run/t6935.scala
index dea2d7f2e2..fdaf02e5ce 100644
--- a/test/files/run/t6935.scala
+++ b/test/files/run/t6935.scala
@@ -1,14 +1,14 @@
object Test {
def main(args: Array[String]): Unit = {
- import java.io._
- val bytes = new ByteArrayOutputStream()
- val out = new ObjectOutputStream(bytes)
- out.writeObject(())
- out.close()
- val buf = bytes.toByteArray
- val in = new ObjectInputStream(new ByteArrayInputStream(buf))
- val unit = in.readObject()
- assert(unit == ())
+ import java.io._
+ val bytes = new ByteArrayOutputStream()
+ val out = new ObjectOutputStream(bytes)
+ out.writeObject(())
+ out.close()
+ val buf = bytes.toByteArray
+ val in = new ObjectInputStream(new ByteArrayInputStream(buf))
+ val unit = in.readObject()
+ assert(unit == ())
}
}