Skip to content

Commit e04aa84

Browse files
authored
Merge pull request #199 from xuwei-k/procedure-syntax
fix procedure syntax
2 parents 9de8085 + 3f03563 commit e04aa84

32 files changed

+172
-172
lines changed

src/main/scala/scala/async/internal/AsyncAnalysis.scala

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,32 +26,32 @@ trait AsyncAnalysis {
2626
private class UnsupportedAwaitAnalyzer extends AsyncTraverser {
2727
var hasUnsupportedAwaits = false
2828

29-
override def nestedClass(classDef: ClassDef) {
29+
override def nestedClass(classDef: ClassDef): Unit = {
3030
val kind = if (classDef.symbol.asClass.isTrait) "trait" else "class"
3131
reportUnsupportedAwait(classDef, s"nested $kind")
3232
}
3333

34-
override def nestedModule(module: ModuleDef) {
34+
override def nestedModule(module: ModuleDef): Unit = {
3535
reportUnsupportedAwait(module, "nested object")
3636
}
3737

38-
override def nestedMethod(defDef: DefDef) {
38+
override def nestedMethod(defDef: DefDef): Unit = {
3939
reportUnsupportedAwait(defDef, "nested method")
4040
}
4141

42-
override def byNameArgument(arg: Tree) {
42+
override def byNameArgument(arg: Tree): Unit = {
4343
reportUnsupportedAwait(arg, "by-name argument")
4444
}
4545

46-
override def function(function: Function) {
46+
override def function(function: Function): Unit = {
4747
reportUnsupportedAwait(function, "nested function")
4848
}
4949

50-
override def patMatFunction(tree: Match) {
50+
override def patMatFunction(tree: Match): Unit = {
5151
reportUnsupportedAwait(tree, "nested function")
5252
}
5353

54-
override def traverse(tree: Tree) {
54+
override def traverse(tree: Tree): Unit = {
5555
tree match {
5656
case Try(_, _, _) if containsAwait(tree) =>
5757
reportUnsupportedAwait(tree, "try/catch")
@@ -94,7 +94,7 @@ trait AsyncAnalysis {
9494
badAwaits.nonEmpty
9595
}
9696

97-
private def reportError(pos: Position, msg: String) {
97+
private def reportError(pos: Position, msg: String): Unit = {
9898
hasUnsupportedAwaits = true
9999
c.abort(pos, msg)
100100
}

src/main/scala/scala/async/internal/AsyncTransform.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ trait AsyncTransform {
117117
cleanupContainsAwaitAttachments(result)
118118
}
119119

120-
def logDiagnostics(anfTree: Tree, states: Seq[String]) {
120+
def logDiagnostics(anfTree: Tree, states: Seq[String]): Unit = {
121121
def location = try {
122122
macroPos.source.path
123123
} catch {

src/main/scala/scala/async/internal/Lifter.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ trait Lifter {
1717
object companionship {
1818
private val companions = collection.mutable.Map[Symbol, Symbol]()
1919
private val companionsInverse = collection.mutable.Map[Symbol, Symbol]()
20-
private def record(sym1: Symbol, sym2: Symbol) {
20+
private def record(sym1: Symbol, sym2: Symbol): Unit = {
2121
companions(sym1) = sym2
2222
companions(sym2) = sym1
2323
}
2424

25-
def record(defs: List[Tree]) {
25+
def record(defs: List[Tree]): Unit = {
2626
// Keep note of local companions so we rename them consistently
2727
// when lifting.
2828
val comps = for {
@@ -86,7 +86,7 @@ trait Lifter {
8686

8787
def liftableSyms: Set[Symbol] = {
8888
val liftableMutableSet = collection.mutable.Set[Symbol]()
89-
def markForLift(sym: Symbol) {
89+
def markForLift(sym: Symbol): Unit = {
9090
if (!liftableMutableSet(sym)) {
9191
liftableMutableSet += sym
9292

src/main/scala/scala/async/internal/LiveVariables.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ trait LiveVariables {
8181
}
8282
private def capturingCheck(tree: Tree) = capturing(tree foreach check)
8383
private var capturing: Boolean = false
84-
private def check(tree: Tree) {
84+
private def check(tree: Tree): Unit = {
8585
tree match {
8686
case Ident(_) if liftedSyms(tree.symbol) =>
8787
if (capturing)

src/main/scala/scala/async/internal/TransformUtils.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -289,25 +289,25 @@ private[async] trait TransformUtils {
289289
* and `nestedClass` etc are invoked.
290290
*/
291291
trait AsyncTraverser extends Traverser {
292-
def nestedClass(classDef: ClassDef) {
292+
def nestedClass(classDef: ClassDef): Unit = {
293293
}
294294

295-
def nestedModule(module: ModuleDef) {
295+
def nestedModule(module: ModuleDef): Unit = {
296296
}
297297

298-
def nestedMethod(defdef: DefDef) {
298+
def nestedMethod(defdef: DefDef): Unit = {
299299
}
300300

301-
def byNameArgument(arg: Tree) {
301+
def byNameArgument(arg: Tree): Unit = {
302302
}
303303

304-
def function(function: Function) {
304+
def function(function: Function): Unit = {
305305
}
306306

307-
def patMatFunction(tree: Match) {
307+
def patMatFunction(tree: Match): Unit = {
308308
}
309309

310-
override def traverse(tree: Tree) {
310+
override def traverse(tree: Tree): Unit = {
311311
tree match {
312312
case _ if isAsync(tree) =>
313313
// Under -Ymacro-expand:discard, used in the IDE, nested async blocks will be visible to the outer blocks

src/test/scala/scala/async/TreeInterrogation.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import tools.reflect.ToolBox
1111

1212
class TreeInterrogation {
1313
@Test
14-
def `a minimal set of vals are lifted to vars`() {
14+
def `a minimal set of vals are lifted to vars`(): Unit = {
1515
val cm = reflect.runtime.currentMirror
1616
val tb = mkToolbox(s"-cp $toolboxClasspath")
1717
val tree = tb.parse(

src/test/scala/scala/async/neg/LocalClasses0Spec.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import scala.async.internal.AsyncId
1010

1111
class LocalClasses0Spec {
1212
@Test
13-
def localClassCrashIssue16() {
13+
def localClassCrashIssue16(): Unit = {
1414
import AsyncId.{async, await}
1515
async {
1616
class B { def f = 1 }
@@ -19,7 +19,7 @@ class LocalClasses0Spec {
1919
}
2020

2121
@Test
22-
def nestedCaseClassAndModuleAllowed() {
22+
def nestedCaseClassAndModuleAllowed(): Unit = {
2323
import AsyncId.{await, async}
2424
async {
2525
trait Base { def base = 0}

src/test/scala/scala/async/neg/NakedAwait.scala

+16-16
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import org.junit.Test
99

1010
class NakedAwait {
1111
@Test
12-
def `await only allowed in async neg`() {
12+
def `await only allowed in async neg`(): Unit = {
1313
expectError("`await` must be enclosed in an `async` block") {
1414
"""
1515
| import _root_.scala.async.Async._
@@ -19,7 +19,7 @@ class NakedAwait {
1919
}
2020

2121
@Test
22-
def `await not allowed in by-name argument`() {
22+
def `await not allowed in by-name argument`(): Unit = {
2323
expectError("await must not be used under a by-name argument.") {
2424
"""
2525
| import _root_.scala.async.internal.AsyncId._
@@ -30,7 +30,7 @@ class NakedAwait {
3030
}
3131

3232
@Test
33-
def `await not allowed in boolean short circuit argument 1`() {
33+
def `await not allowed in boolean short circuit argument 1`(): Unit = {
3434
expectError("await must not be used under a by-name argument.") {
3535
"""
3636
| import _root_.scala.async.internal.AsyncId._
@@ -40,7 +40,7 @@ class NakedAwait {
4040
}
4141

4242
@Test
43-
def `await not allowed in boolean short circuit argument 2`() {
43+
def `await not allowed in boolean short circuit argument 2`(): Unit = {
4444
expectError("await must not be used under a by-name argument.") {
4545
"""
4646
| import _root_.scala.async.internal.AsyncId._
@@ -50,7 +50,7 @@ class NakedAwait {
5050
}
5151

5252
@Test
53-
def nestedObject() {
53+
def nestedObject(): Unit = {
5454
expectError("await must not be used under a nested object.") {
5555
"""
5656
| import _root_.scala.async.internal.AsyncId._
@@ -60,7 +60,7 @@ class NakedAwait {
6060
}
6161

6262
@Test
63-
def nestedTrait() {
63+
def nestedTrait(): Unit = {
6464
expectError("await must not be used under a nested trait.") {
6565
"""
6666
| import _root_.scala.async.internal.AsyncId._
@@ -70,7 +70,7 @@ class NakedAwait {
7070
}
7171

7272
@Test
73-
def nestedClass() {
73+
def nestedClass(): Unit = {
7474
expectError("await must not be used under a nested class.") {
7575
"""
7676
| import _root_.scala.async.internal.AsyncId._
@@ -80,7 +80,7 @@ class NakedAwait {
8080
}
8181

8282
@Test
83-
def nestedFunction() {
83+
def nestedFunction(): Unit = {
8484
expectError("await must not be used under a nested function.") {
8585
"""
8686
| import _root_.scala.async.internal.AsyncId._
@@ -90,7 +90,7 @@ class NakedAwait {
9090
}
9191

9292
@Test
93-
def nestedPatMatFunction() {
93+
def nestedPatMatFunction(): Unit = {
9494
expectError("await must not be used under a nested class.") { // TODO more specific error message
9595
"""
9696
| import _root_.scala.async.internal.AsyncId._
@@ -100,7 +100,7 @@ class NakedAwait {
100100
}
101101

102102
@Test
103-
def tryBody() {
103+
def tryBody(): Unit = {
104104
expectError("await must not be used under a try/catch.") {
105105
"""
106106
| import _root_.scala.async.internal.AsyncId._
@@ -110,7 +110,7 @@ class NakedAwait {
110110
}
111111

112112
@Test
113-
def catchBody() {
113+
def catchBody(): Unit = {
114114
expectError("await must not be used under a try/catch.") {
115115
"""
116116
| import _root_.scala.async.internal.AsyncId._
@@ -120,7 +120,7 @@ class NakedAwait {
120120
}
121121

122122
@Test
123-
def finallyBody() {
123+
def finallyBody(): Unit = {
124124
expectError("await must not be used under a try/catch.") {
125125
"""
126126
| import _root_.scala.async.internal.AsyncId._
@@ -130,7 +130,7 @@ class NakedAwait {
130130
}
131131

132132
@Test
133-
def guard() {
133+
def guard(): Unit = {
134134
expectError("await must not be used under a pattern guard.") {
135135
"""
136136
| import _root_.scala.async.internal.AsyncId._
@@ -140,7 +140,7 @@ class NakedAwait {
140140
}
141141

142142
@Test
143-
def nestedMethod() {
143+
def nestedMethod(): Unit = {
144144
expectError("await must not be used under a nested method.") {
145145
"""
146146
| import _root_.scala.async.internal.AsyncId._
@@ -150,7 +150,7 @@ class NakedAwait {
150150
}
151151

152152
@Test
153-
def returnIllegal() {
153+
def returnIllegal(): Unit = {
154154
expectError("return is illegal") {
155155
"""
156156
| import _root_.scala.async.internal.AsyncId._
@@ -162,7 +162,7 @@ class NakedAwait {
162162
}
163163

164164
@Test
165-
def lazyValIllegal() {
165+
def lazyValIllegal(): Unit = {
166166
expectError("await must not be used under a lazy val initializer") {
167167
"""
168168
| import _root_.scala.async.internal.AsyncId._

src/test/scala/scala/async/neg/SampleNegSpec.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import org.junit.Test
99

1010
class SampleNegSpec {
1111
@Test
12-
def `missing symbol`() {
12+
def `missing symbol`(): Unit = {
1313
expectError("not found: value kaboom") {
1414
"""
1515
| kaboom

src/test/scala/scala/async/package.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ package object async {
7474
.getParentFile.getParentFile
7575

7676
def expectError(errorSnippet: String, compileOptions: String = "",
77-
baseCompileOptions: String = s"-cp ${toolboxClasspath}")(code: String) {
77+
baseCompileOptions: String = s"-cp ${toolboxClasspath}")(code: String): Unit = {
7878
intercept[ToolBoxError] {
7979
eval(code, compileOptions + " " + baseCompileOptions)
8080
}.getMessage mustContain errorSnippet

src/test/scala/scala/async/run/WarningsSpec.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class WarningsSpec {
3333

3434
@Test
3535
// https://github.com/scala/async/issues/74
36-
def noDeadCodeWarningForAsyncThrow() {
36+
def noDeadCodeWarningForAsyncThrow(): Unit = {
3737
val global = mkGlobal("-cp ${toolboxClasspath} -Yrangepos -Ywarn-dead-code -Xfatal-warnings -Ystop-after:refchecks")
3838
// was: "a pure expression does nothing in statement position; you may be omitting necessary parentheses"
3939
val source =
@@ -51,7 +51,7 @@ class WarningsSpec {
5151
}
5252

5353
@Test
54-
def noDeadCodeWarningInMacroExpansion() {
54+
def noDeadCodeWarningInMacroExpansion(): Unit = {
5555
val global = mkGlobal("-cp ${toolboxClasspath} -Yrangepos -Ywarn-dead-code -Xfatal-warnings -Ystop-after:refchecks")
5656
val source = """
5757
| class Test {
@@ -76,7 +76,7 @@ class WarningsSpec {
7676
}
7777

7878
@Test
79-
def ignoreNestedAwaitsInIDE_t1002561() {
79+
def ignoreNestedAwaitsInIDE_t1002561(): Unit = {
8080
// https://www.assembla.com/spaces/scala-ide/tickets/1002561
8181
val global = mkGlobal("-cp ${toolboxClasspath} -Yrangepos -Ystop-after:typer ")
8282
val source = """

0 commit comments

Comments
 (0)