summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-04-28 16:26:05 +0000
committerPaul Phillips <paulp@improving.org>2011-04-28 16:26:05 +0000
commitc5d9b7e6a99f253d6da941610c58d9d9e1a02925 (patch)
tree461c02007998ff775201b6860843b555f4ae3bfc /test
parent199ec3c10fe7d2b2029ea8ae6a19240b46181435 (diff)
downloadscala-c5d9b7e6a99f253d6da941610c58d9d9e1a02925.tar.gz
scala-c5d9b7e6a99f253d6da941610c58d9d9e1a02925.tar.bz2
scala-c5d9b7e6a99f253d6da941610c58d9d9e1a02925.zip
I wrote a warning when nullary methods return U...
I wrote a warning when nullary methods return Unit. I wimped out of including it in this patch because we had about 200 of them, and that's what is fixed in this patch. I will add the warning to some kind of "-Xlint" feature after 2.9. This is motivated at least partly by the resolution of #4506, which indicates the distinction between "def foo()" and "def foo" will continue to jab its pointy stick into our eyes, so I believe we have a minimal duty of at least following our own advice about what they mean and not making a semirandom choice as to whether a method has parens or not. Review by community.
Diffstat (limited to 'test')
-rw-r--r--test/files/buildmanager/t3054/foo/Foo.scala2
-rw-r--r--test/files/buildmanager/t4215/A.scala2
-rw-r--r--test/files/continuations-neg/lazy.check4
-rw-r--r--test/files/continuations-neg/lazy.scala4
-rw-r--r--test/files/neg/accesses.check16
-rw-r--r--test/files/neg/accesses.scala32
-rw-r--r--test/files/neg/bug1960.check2
-rw-r--r--test/files/neg/bug1960.scala2
-rw-r--r--test/files/neg/bug630.scala4
-rw-r--r--test/files/neg/patmatexhaust.scala6
-rw-r--r--test/files/neg/t2910.check2
-rw-r--r--test/files/neg/t2910.scala4
-rw-r--r--test/files/neg/tailrec.scala2
-rw-r--r--test/files/res/bug722/Parser.scala2
-rw-r--r--test/files/res/bug722/ScanBased.scala4
-rw-r--r--test/files/res/bug785/ScalaNewTyper.scala2
16 files changed, 45 insertions, 45 deletions
diff --git a/test/files/buildmanager/t3054/foo/Foo.scala b/test/files/buildmanager/t3054/foo/Foo.scala
index c4838b9958..c0fcd97390 100644
--- a/test/files/buildmanager/t3054/foo/Foo.scala
+++ b/test/files/buildmanager/t3054/foo/Foo.scala
@@ -1,5 +1,5 @@
package foo
class Foo {
- def foo = println("foo")
+ def foo() = println("foo")
}
diff --git a/test/files/buildmanager/t4215/A.scala b/test/files/buildmanager/t4215/A.scala
index fbddd93afc..9db40b0fee 100644
--- a/test/files/buildmanager/t4215/A.scala
+++ b/test/files/buildmanager/t4215/A.scala
@@ -1,5 +1,5 @@
class A {
- def B {
+ def B() {
object C
}
}
diff --git a/test/files/continuations-neg/lazy.check b/test/files/continuations-neg/lazy.check
index bfa44c59a4..b8c6887409 100644
--- a/test/files/continuations-neg/lazy.check
+++ b/test/files/continuations-neg/lazy.check
@@ -1,6 +1,6 @@
lazy.scala:5: error: type mismatch;
found : Unit @scala.util.continuations.cpsParam[Unit,Unit]
required: Unit
- def foo = {
- ^
+ def foo() = {
+ ^
one error found
diff --git a/test/files/continuations-neg/lazy.scala b/test/files/continuations-neg/lazy.scala
index dffc57ffa0..3c8169dd46 100644
--- a/test/files/continuations-neg/lazy.scala
+++ b/test/files/continuations-neg/lazy.scala
@@ -2,14 +2,14 @@ import scala.util.continuations._
object Test {
- def foo = {
+ def foo() = {
lazy val x = shift((k:Unit=>Unit)=>k())
println(x)
}
def main(args: Array[String]) {
reset {
- foo
+ foo()
}
}
diff --git a/test/files/neg/accesses.check b/test/files/neg/accesses.check
index 94fcd615bc..db58af12ce 100644
--- a/test/files/neg/accesses.check
+++ b/test/files/neg/accesses.check
@@ -1,17 +1,17 @@
-accesses.scala:23: error: overriding method f2 in class A of type => Unit;
+accesses.scala:23: error: overriding method f2 in class A of type ()Unit;
method f2 has weaker access privileges; it should not be private
- private def f2: Unit = ()
+ private def f2(): Unit = ()
^
-accesses.scala:24: error: overriding method f3 in class A of type => Unit;
+accesses.scala:24: error: overriding method f3 in class A of type ()Unit;
method f3 has weaker access privileges; it should be at least protected
- private[p2] def f3: Unit = ()
+ private[p2] def f3(): Unit = ()
^
-accesses.scala:25: error: overriding method f4 in class A of type => Unit;
+accesses.scala:25: error: overriding method f4 in class A of type ()Unit;
method f4 has weaker access privileges; it should be at least private[p1]
- private[p2] def f4: Unit
+ private[p2] def f4(): Unit
^
-accesses.scala:26: error: overriding method f5 in class A of type => Unit;
+accesses.scala:26: error: overriding method f5 in class A of type ()Unit;
method f5 has weaker access privileges; it should be at least protected[p1]
- protected[p2] def f5: Unit
+ protected[p2] def f5(): Unit
^
four errors found
diff --git a/test/files/neg/accesses.scala b/test/files/neg/accesses.scala
index 2a6b45c35b..b1df6c0e6c 100644
--- a/test/files/neg/accesses.scala
+++ b/test/files/neg/accesses.scala
@@ -1,27 +1,27 @@
package test.p1.p2
abstract class A {
- private[p2] def f2: Unit
- protected def f3: Unit
- private[p1] def f4: Unit
- protected[p1] def f5: Unit
+ private[p2] def f2(): Unit
+ protected def f3(): Unit
+ private[p1] def f4(): Unit
+ protected[p1] def f5(): Unit
}
abstract class OK1 extends A {
- private[p1] def f2: Unit
- protected[p2] def f3: Unit
- private[test] def f4: Unit
- protected[test] def f5: Unit
+ private[p1] def f2(): Unit
+ protected[p2] def f3(): Unit
+ private[test] def f4(): Unit
+ protected[test] def f5(): Unit
}
abstract class OK2 extends A {
- protected[p1] def f2: Unit
- def f3: Unit
- protected[p1] def f4: Unit
- def f5: Unit
+ protected[p1] def f2(): Unit
+ def f3(): Unit
+ protected[p1] def f4(): Unit
+ def f5(): Unit
}
abstract class Err1 extends A {
- private def f2: Unit = ()
- private[p2] def f3: Unit = ()
- private[p2] def f4: Unit
- protected[p2] def f5: Unit
+ private def f2(): Unit = ()
+ private[p2] def f3(): Unit = ()
+ private[p2] def f4(): Unit
+ protected[p2] def f5(): Unit
}
diff --git a/test/files/neg/bug1960.check b/test/files/neg/bug1960.check
index 6615d90036..8e19f31ef5 100644
--- a/test/files/neg/bug1960.check
+++ b/test/files/neg/bug1960.check
@@ -1,4 +1,4 @@
bug1960.scala:5: error: parameter 'p' requires field but conflicts with p in 'TBase'
-class Aclass (p: Int) extends TBase { def g{ f(p) } }
+class Aclass (p: Int) extends TBase { def g() { f(p) } }
^
one error found
diff --git a/test/files/neg/bug1960.scala b/test/files/neg/bug1960.scala
index af7f270356..5311940b5a 100644
--- a/test/files/neg/bug1960.scala
+++ b/test/files/neg/bug1960.scala
@@ -2,4 +2,4 @@ object ClassFormatErrorExample extends App { new Aclass(1) }
trait TBase { var p:Int = 0; def f(p1: Int) {} }
-class Aclass (p: Int) extends TBase { def g{ f(p) } }
+class Aclass (p: Int) extends TBase { def g() { f(p) } }
diff --git a/test/files/neg/bug630.scala b/test/files/neg/bug630.scala
index d236b51ffd..8a073963b0 100644
--- a/test/files/neg/bug630.scala
+++ b/test/files/neg/bug630.scala
@@ -1,7 +1,7 @@
trait Req1
trait Req2 {
- def test = Console.println("Test")
+ def test() = Console.println("Test")
}
trait Foo {
@@ -10,7 +10,7 @@ trait Foo {
trait Bar {
val foo : Req2
- def test = foo.test
+ def test() = foo.test
}
object Test
diff --git a/test/files/neg/patmatexhaust.scala b/test/files/neg/patmatexhaust.scala
index b172df8740..4a66649a18 100644
--- a/test/files/neg/patmatexhaust.scala
+++ b/test/files/neg/patmatexhaust.scala
@@ -56,12 +56,12 @@ class TestSealedExhaustive { // compile only
case Ga =>
}
- def ma6 = List(1,2) match { // give up
+ def ma6() = List(1,2) match { // give up
case List(1,2) =>
case x :: xs =>
}
- def ma7 = List(1,2) match { //exhaustive
+ def ma7() = List(1,2) match { //exhaustive
case 1::2::Nil =>
case _ =>
}
@@ -87,7 +87,7 @@ class TestSealedExhaustive { // compile only
case C2 | C6 => true
}
- def redundant = 1 match { // include this otherwise script won't test this in files/neg
+ def redundant() = 1 match { // include this otherwise script won't test this in files/neg
case 1 =>
case 1 =>
}
diff --git a/test/files/neg/t2910.check b/test/files/neg/t2910.check
index afff73ec08..ff190122d6 100644
--- a/test/files/neg/t2910.check
+++ b/test/files/neg/t2910.check
@@ -13,4 +13,4 @@ t2910.scala:30: error: forward reference extends over definition of value x
t2910.scala:34: error: forward reference extends over definition of variable x
lazy val f: Int = g
^
-5 errors found \ No newline at end of file
+5 errors found
diff --git a/test/files/neg/t2910.scala b/test/files/neg/t2910.scala
index 1c7ba54971..b772ee4d43 100644
--- a/test/files/neg/t2910.scala
+++ b/test/files/neg/t2910.scala
@@ -5,13 +5,13 @@ object Junk {
ret
}
- def test2 {
+ def test2() {
println(s.length)
val z = 0
lazy val s = "abc"
}
- def test4 {
+ def test4() {
lazy val x = {
x
val z = 0
diff --git a/test/files/neg/tailrec.scala b/test/files/neg/tailrec.scala
index a77f439cfe..e0ebde9863 100644
--- a/test/files/neg/tailrec.scala
+++ b/test/files/neg/tailrec.scala
@@ -10,7 +10,7 @@ object Winners {
@tailrec def loopsucc1(x: Int): Int = loopsucc1(x - 1)
@tailrec def loopsucc2[T](x: Int): Int = loopsucc2[T](x - 1)
- def ding {
+ def ding() {
object dong {
@tailrec def loopsucc3(x: Int): Int = loopsucc3(x)
}
diff --git a/test/files/res/bug722/Parser.scala b/test/files/res/bug722/Parser.scala
index 6d9739ed04..7f84cb2b63 100644
--- a/test/files/res/bug722/Parser.scala
+++ b/test/files/res/bug722/Parser.scala
@@ -2,7 +2,7 @@
package bug722;
trait Parser {
trait Link {
- def foo = {}
+ def foo() = {}
}
}
diff --git a/test/files/res/bug722/ScanBased.scala b/test/files/res/bug722/ScanBased.scala
index fcb853f96d..4793a04914 100644
--- a/test/files/res/bug722/ScanBased.scala
+++ b/test/files/res/bug722/ScanBased.scala
@@ -1,10 +1,10 @@
package bug722;
trait ScanBased extends Parser {
trait AdjacentLink extends Link {
- override def foo = super.foo;
+ override def foo() = super.foo;
}
trait WhitespaceLink extends AdjacentLink {
- override def foo = super.foo;
+ override def foo() = super.foo;
}
}
diff --git a/test/files/res/bug785/ScalaNewTyper.scala b/test/files/res/bug785/ScalaNewTyper.scala
index fb955572ed..d55d60a8d0 100644
--- a/test/files/res/bug785/ScalaNewTyper.scala
+++ b/test/files/res/bug785/ScalaNewTyper.scala
@@ -2,7 +2,7 @@ package bug785;
trait ScalaNewTyper {
private var typed : String = null;
trait HasSymbol {
- protected def foo : Unit = {}
+ protected def foo() : Unit = {}
}
trait HasArgsTypeParametersImpl extends HasSymbol {
private var argss : List[List[String]] = Nil;