Skip to content

fix procedure syntax #199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/main/scala/scala/async/internal/AsyncAnalysis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,32 @@ trait AsyncAnalysis {
private class UnsupportedAwaitAnalyzer extends AsyncTraverser {
var hasUnsupportedAwaits = false

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

override def nestedModule(module: ModuleDef) {
override def nestedModule(module: ModuleDef): Unit = {
reportUnsupportedAwait(module, "nested object")
}

override def nestedMethod(defDef: DefDef) {
override def nestedMethod(defDef: DefDef): Unit = {
reportUnsupportedAwait(defDef, "nested method")
}

override def byNameArgument(arg: Tree) {
override def byNameArgument(arg: Tree): Unit = {
reportUnsupportedAwait(arg, "by-name argument")
}

override def function(function: Function) {
override def function(function: Function): Unit = {
reportUnsupportedAwait(function, "nested function")
}

override def patMatFunction(tree: Match) {
override def patMatFunction(tree: Match): Unit = {
reportUnsupportedAwait(tree, "nested function")
}

override def traverse(tree: Tree) {
override def traverse(tree: Tree): Unit = {
tree match {
case Try(_, _, _) if containsAwait(tree) =>
reportUnsupportedAwait(tree, "try/catch")
Expand Down Expand Up @@ -94,7 +94,7 @@ trait AsyncAnalysis {
badAwaits.nonEmpty
}

private def reportError(pos: Position, msg: String) {
private def reportError(pos: Position, msg: String): Unit = {
hasUnsupportedAwaits = true
c.abort(pos, msg)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/scala/async/internal/AsyncTransform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ trait AsyncTransform {
cleanupContainsAwaitAttachments(result)
}

def logDiagnostics(anfTree: Tree, states: Seq[String]) {
def logDiagnostics(anfTree: Tree, states: Seq[String]): Unit = {
def location = try {
macroPos.source.path
} catch {
Expand Down
6 changes: 3 additions & 3 deletions src/main/scala/scala/async/internal/Lifter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ trait Lifter {
object companionship {
private val companions = collection.mutable.Map[Symbol, Symbol]()
private val companionsInverse = collection.mutable.Map[Symbol, Symbol]()
private def record(sym1: Symbol, sym2: Symbol) {
private def record(sym1: Symbol, sym2: Symbol): Unit = {
companions(sym1) = sym2
companions(sym2) = sym1
}

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

def liftableSyms: Set[Symbol] = {
val liftableMutableSet = collection.mutable.Set[Symbol]()
def markForLift(sym: Symbol) {
def markForLift(sym: Symbol): Unit = {
if (!liftableMutableSet(sym)) {
liftableMutableSet += sym

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/scala/async/internal/LiveVariables.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ trait LiveVariables {
}
private def capturingCheck(tree: Tree) = capturing(tree foreach check)
private var capturing: Boolean = false
private def check(tree: Tree) {
private def check(tree: Tree): Unit = {
tree match {
case Ident(_) if liftedSyms(tree.symbol) =>
if (capturing)
Expand Down
14 changes: 7 additions & 7 deletions src/main/scala/scala/async/internal/TransformUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -289,25 +289,25 @@ private[async] trait TransformUtils {
* and `nestedClass` etc are invoked.
*/
trait AsyncTraverser extends Traverser {
def nestedClass(classDef: ClassDef) {
def nestedClass(classDef: ClassDef): Unit = {
}

def nestedModule(module: ModuleDef) {
def nestedModule(module: ModuleDef): Unit = {
}

def nestedMethod(defdef: DefDef) {
def nestedMethod(defdef: DefDef): Unit = {
}

def byNameArgument(arg: Tree) {
def byNameArgument(arg: Tree): Unit = {
}

def function(function: Function) {
def function(function: Function): Unit = {
}

def patMatFunction(tree: Match) {
def patMatFunction(tree: Match): Unit = {
}

override def traverse(tree: Tree) {
override def traverse(tree: Tree): Unit = {
tree match {
case _ if isAsync(tree) =>
// Under -Ymacro-expand:discard, used in the IDE, nested async blocks will be visible to the outer blocks
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/scala/async/TreeInterrogation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import tools.reflect.ToolBox

class TreeInterrogation {
@Test
def `a minimal set of vals are lifted to vars`() {
def `a minimal set of vals are lifted to vars`(): Unit = {
val cm = reflect.runtime.currentMirror
val tb = mkToolbox(s"-cp $toolboxClasspath")
val tree = tb.parse(
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/scala/async/neg/LocalClasses0Spec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import scala.async.internal.AsyncId

class LocalClasses0Spec {
@Test
def localClassCrashIssue16() {
def localClassCrashIssue16(): Unit = {
import AsyncId.{async, await}
async {
class B { def f = 1 }
Expand All @@ -19,7 +19,7 @@ class LocalClasses0Spec {
}

@Test
def nestedCaseClassAndModuleAllowed() {
def nestedCaseClassAndModuleAllowed(): Unit = {
import AsyncId.{await, async}
async {
trait Base { def base = 0}
Expand Down
32 changes: 16 additions & 16 deletions src/test/scala/scala/async/neg/NakedAwait.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.junit.Test

class NakedAwait {
@Test
def `await only allowed in async neg`() {
def `await only allowed in async neg`(): Unit = {
expectError("`await` must be enclosed in an `async` block") {
"""
| import _root_.scala.async.Async._
Expand All @@ -19,7 +19,7 @@ class NakedAwait {
}

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

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

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

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

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

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

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

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

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

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

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

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

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

@Test
def returnIllegal() {
def returnIllegal(): Unit = {
expectError("return is illegal") {
"""
| import _root_.scala.async.internal.AsyncId._
Expand All @@ -162,7 +162,7 @@ class NakedAwait {
}

@Test
def lazyValIllegal() {
def lazyValIllegal(): Unit = {
expectError("await must not be used under a lazy val initializer") {
"""
| import _root_.scala.async.internal.AsyncId._
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/scala/async/neg/SampleNegSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.junit.Test

class SampleNegSpec {
@Test
def `missing symbol`() {
def `missing symbol`(): Unit = {
expectError("not found: value kaboom") {
"""
| kaboom
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/scala/async/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ package object async {
.getParentFile.getParentFile

def expectError(errorSnippet: String, compileOptions: String = "",
baseCompileOptions: String = s"-cp ${toolboxClasspath}")(code: String) {
baseCompileOptions: String = s"-cp ${toolboxClasspath}")(code: String): Unit = {
intercept[ToolBoxError] {
eval(code, compileOptions + " " + baseCompileOptions)
}.getMessage mustContain errorSnippet
Expand Down
6 changes: 3 additions & 3 deletions src/test/scala/scala/async/run/WarningsSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class WarningsSpec {

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

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

@Test
def ignoreNestedAwaitsInIDE_t1002561() {
def ignoreNestedAwaitsInIDE_t1002561(): Unit = {
// https://www.assembla.com/spaces/scala-ide/tickets/1002561
val global = mkGlobal("-cp ${toolboxClasspath} -Yrangepos -Ystop-after:typer ")
val source = """
Expand Down
Loading