From 2d8506a64392cd7192b6831c38798cc9a7c8bfed Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 7 Jul 2013 10:48:11 +1000 Subject: Move implementation details to scala.async.internal._. If we intend to keep CPS fallback around for any length of time it should probably move there too. --- src/test/scala/scala/async/TreeInterrogation.scala | 5 ++-- .../scala/scala/async/neg/LocalClasses0Spec.scala | 3 +- src/test/scala/scala/async/neg/NakedAwait.scala | 28 ++++++++--------- .../scala/async/run/anf/AnfTransformSpec.scala | 35 ++++++++++------------ .../scala/scala/async/run/hygiene/Hygiene.scala | 3 +- .../scala/scala/async/run/ifelse0/IfElse0.scala | 1 + .../scala/scala/async/run/ifelse0/WhileSpec.scala | 3 +- src/test/scala/scala/async/run/match0/Match0.scala | 1 + .../scala/async/run/nesteddef/NestedDef.scala | 1 + .../scala/async/run/noawait/NoAwaitSpec.scala | 1 + .../scala/async/run/toughtype/ToughType.scala | 7 +++-- 11 files changed, 47 insertions(+), 41 deletions(-) (limited to 'src/test') diff --git a/src/test/scala/scala/async/TreeInterrogation.scala b/src/test/scala/scala/async/TreeInterrogation.scala index 86a7157..f1cb251 100644 --- a/src/test/scala/scala/async/TreeInterrogation.scala +++ b/src/test/scala/scala/async/TreeInterrogation.scala @@ -7,6 +7,7 @@ package scala.async import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.junit.Test +import scala.async.internal.AsyncId import AsyncId._ import tools.reflect.ToolBox @@ -17,7 +18,7 @@ class TreeInterrogation { val cm = reflect.runtime.currentMirror val tb = mkToolbox(s"-cp ${toolboxClasspath}") val tree = tb.parse( - """| import _root_.scala.async.AsyncId._ + """| import _root_.scala.async.internal.AsyncId._ | async { | val x = await(1) | val y = x * 2 @@ -70,7 +71,7 @@ object TreeInterrogation extends App { val tb = mkToolbox("-cp ${toolboxClasspath} -Xprint:typer -uniqid") import scala.async.Async._ val tree = tb.parse( - """ import _root_.scala.async.AsyncId.{async, await} + """ import _root_.scala.async.internal.AsyncId.{async, await} | def foo[T](a0: Int)(b0: Int*) = s"a0 = $a0, b0 = ${b0.head}" | val res = async { | var i = 0 diff --git a/src/test/scala/scala/async/neg/LocalClasses0Spec.scala b/src/test/scala/scala/async/neg/LocalClasses0Spec.scala index dcd9bb8..6ebc9ca 100644 --- a/src/test/scala/scala/async/neg/LocalClasses0Spec.scala +++ b/src/test/scala/scala/async/neg/LocalClasses0Spec.scala @@ -8,12 +8,13 @@ package neg import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.junit.Test +import scala.async.internal.AsyncId @RunWith(classOf[JUnit4]) class LocalClasses0Spec { @Test def localClassCrashIssue16() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} async { class B { def f = 1 } await(new B()).f diff --git a/src/test/scala/scala/async/neg/NakedAwait.scala b/src/test/scala/scala/async/neg/NakedAwait.scala index b0d5fde..aa62d37 100644 --- a/src/test/scala/scala/async/neg/NakedAwait.scala +++ b/src/test/scala/scala/async/neg/NakedAwait.scala @@ -25,7 +25,7 @@ class NakedAwait { def `await not allowed in by-name argument`() { expectError("await must not be used under a by-name argument.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | def foo(a: Int)(b: => Int) = 0 | async { foo(0)(await(0)) } """.stripMargin @@ -36,7 +36,7 @@ class NakedAwait { def `await not allowed in boolean short circuit argument 1`() { expectError("await must not be used under a by-name argument.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { true && await(false) } """.stripMargin } @@ -46,7 +46,7 @@ class NakedAwait { def `await not allowed in boolean short circuit argument 2`() { expectError("await must not be used under a by-name argument.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { true || await(false) } """.stripMargin } @@ -56,7 +56,7 @@ class NakedAwait { def nestedObject() { expectError("await must not be used under a nested object.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { object Nested { await(false) } } """.stripMargin } @@ -66,7 +66,7 @@ class NakedAwait { def nestedTrait() { expectError("await must not be used under a nested trait.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { trait Nested { await(false) } } """.stripMargin } @@ -76,7 +76,7 @@ class NakedAwait { def nestedClass() { expectError("await must not be used under a nested class.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { class Nested { await(false) } } """.stripMargin } @@ -86,7 +86,7 @@ class NakedAwait { def nestedFunction() { expectError("await must not be used under a nested function.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { () => { await(false) } } """.stripMargin } @@ -96,7 +96,7 @@ class NakedAwait { def nestedPatMatFunction() { expectError("await must not be used under a nested class.") { // TODO more specific error message """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { { case x => { await(false) } } : PartialFunction[Any, Any] } """.stripMargin } @@ -106,7 +106,7 @@ class NakedAwait { def tryBody() { expectError("await must not be used under a try/catch.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { try { await(false) } catch { case _ => } } """.stripMargin } @@ -116,7 +116,7 @@ class NakedAwait { def catchBody() { expectError("await must not be used under a try/catch.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { try { () } catch { case _ => await(false) } } """.stripMargin } @@ -126,7 +126,7 @@ class NakedAwait { def finallyBody() { expectError("await must not be used under a try/catch.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { try { () } finally { await(false) } } """.stripMargin } @@ -136,7 +136,7 @@ class NakedAwait { def nestedMethod() { expectError("await must not be used under a nested method.") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | async { def foo = await(false) } """.stripMargin } @@ -146,7 +146,7 @@ class NakedAwait { def returnIllegal() { expectError("return is illegal") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | def foo(): Any = async { return false } | () | @@ -158,7 +158,7 @@ class NakedAwait { def lazyValIllegal() { expectError("lazy vals are illegal") { """ - | import _root_.scala.async.AsyncId._ + | import _root_.scala.async.internal.AsyncId._ | def foo(): Any = async { val x = { lazy val y = 0; y } } | () | diff --git a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala index abce3ce..e389a19 100644 --- a/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala +++ b/src/test/scala/scala/async/run/anf/AnfTransformSpec.scala @@ -13,6 +13,7 @@ import scala.async.Async.{async, await} import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import scala.async.internal.AsyncId class AnfTestClass { @@ -114,8 +115,6 @@ class AnfTransformSpec { @Test def `inlining block does not produce duplicate definition`() { - import scala.async.AsyncId - AsyncId.async { val f = 12 val x = AsyncId.await(f) @@ -132,8 +131,6 @@ class AnfTransformSpec { @Test def `inlining block in tail position does not produce duplicate definition`() { - import scala.async.AsyncId - AsyncId.async { val f = 12 val x = AsyncId.await(f) @@ -176,7 +173,7 @@ class AnfTransformSpec { @Test def nestedAwaitAsBareExpression() { import ExecutionContext.Implicits.global - import _root_.scala.async.AsyncId.{async, await} + import AsyncId.{async, await} val result = async { await(await("").isEmpty) } @@ -186,7 +183,7 @@ class AnfTransformSpec { @Test def nestedAwaitInBlock() { import ExecutionContext.Implicits.global - import _root_.scala.async.AsyncId.{async, await} + import AsyncId.{async, await} val result = async { () await(await("").isEmpty) @@ -197,7 +194,7 @@ class AnfTransformSpec { @Test def nestedAwaitInIf() { import ExecutionContext.Implicits.global - import _root_.scala.async.AsyncId.{async, await} + import AsyncId.{async, await} val result = async { if ("".isEmpty) await(await("").isEmpty) @@ -208,7 +205,7 @@ class AnfTransformSpec { @Test def byNameExpressionsArentLifted() { - import _root_.scala.async.AsyncId.{async, await} + import AsyncId.{async, await} def foo(ignored: => Any, b: Int) = b val result = async { foo(???, await(1)) @@ -218,7 +215,7 @@ class AnfTransformSpec { @Test def evaluationOrderRespected() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} def foo(a: Int, b: Int) = (a, b) val result = async { var i = 0 @@ -233,7 +230,7 @@ class AnfTransformSpec { @Test def awaitInNonPrimaryParamSection1() { - import _root_.scala.async.AsyncId.{async, await} + import AsyncId.{async, await} def foo(a0: Int)(b0: Int) = s"a0 = $a0, b0 = $b0" val res = async { var i = 0 @@ -245,7 +242,7 @@ class AnfTransformSpec { @Test def awaitInNonPrimaryParamSection2() { - import _root_.scala.async.AsyncId.{async, await} + import AsyncId.{async, await} def foo[T](a0: Int)(b0: Int*) = s"a0 = $a0, b0 = ${b0.head}" val res = async { var i = 0 @@ -257,7 +254,7 @@ class AnfTransformSpec { @Test def awaitInNonPrimaryParamSectionWithLazy1() { - import _root_.scala.async.AsyncId.{async, await} + import AsyncId.{async, await} def foo[T](a: => Int)(b: Int) = b val res = async { def get = async {0} @@ -268,7 +265,7 @@ class AnfTransformSpec { @Test def awaitInNonPrimaryParamSectionWithLazy2() { - import _root_.scala.async.AsyncId.{async, await} + import AsyncId.{async, await} def foo[T](a: Int)(b: => Int) = a val res = async { def get = async {0} @@ -279,7 +276,7 @@ class AnfTransformSpec { @Test def awaitWithLazy() { - import _root_.scala.async.AsyncId.{async, await} + import AsyncId.{async, await} def foo[T](a: Int, b: => Int) = a val res = async { def get = async {0} @@ -290,7 +287,7 @@ class AnfTransformSpec { @Test def awaitOkInReciever() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} class Foo { def bar(a: Int)(b: Int) = a + b } async { await(async(new Foo)).bar(1)(2) @@ -299,7 +296,7 @@ class AnfTransformSpec { @Test def namedArgumentsRespectEvaluationOrder() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} def foo(a: Int, b: Int) = (a, b) val result = async { var i = 0 @@ -314,7 +311,7 @@ class AnfTransformSpec { @Test def namedAndDefaultArgumentsRespectEvaluationOrder() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} var i = 0 def next() = { i += 1; @@ -332,7 +329,7 @@ class AnfTransformSpec { @Test def repeatedParams1() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} var i = 0 def foo(a: Int, b: Int*) = b.toList def id(i: Int) = i @@ -343,7 +340,7 @@ class AnfTransformSpec { @Test def repeatedParams2() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} var i = 0 def foo(a: Int, b: Int*) = b.toList def id(i: Int) = i diff --git a/src/test/scala/scala/async/run/hygiene/Hygiene.scala b/src/test/scala/scala/async/run/hygiene/Hygiene.scala index 9d1df21..8081ee7 100644 --- a/src/test/scala/scala/async/run/hygiene/Hygiene.scala +++ b/src/test/scala/scala/async/run/hygiene/Hygiene.scala @@ -9,11 +9,12 @@ package hygiene import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import scala.async.internal.AsyncId @RunWith(classOf[JUnit4]) class HygieneSpec { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} @Test def `is hygenic`() { diff --git a/src/test/scala/scala/async/run/ifelse0/IfElse0.scala b/src/test/scala/scala/async/run/ifelse0/IfElse0.scala index e2b1ca6..fc438a1 100644 --- a/src/test/scala/scala/async/run/ifelse0/IfElse0.scala +++ b/src/test/scala/scala/async/run/ifelse0/IfElse0.scala @@ -13,6 +13,7 @@ import scala.async.Async.{async, await} import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.junit.Test +import scala.async.internal.AsyncId class TestIfElseClass { diff --git a/src/test/scala/scala/async/run/ifelse0/WhileSpec.scala b/src/test/scala/scala/async/run/ifelse0/WhileSpec.scala index 1f1033a..b8d88fb 100644 --- a/src/test/scala/scala/async/run/ifelse0/WhileSpec.scala +++ b/src/test/scala/scala/async/run/ifelse0/WhileSpec.scala @@ -9,6 +9,7 @@ package ifelse0 import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.junit.Test +import scala.async.internal.AsyncId @RunWith(classOf[JUnit4]) class WhileSpec { @@ -64,4 +65,4 @@ class WhileSpec { } result mustBe (100) } -} \ No newline at end of file +} diff --git a/src/test/scala/scala/async/run/match0/Match0.scala b/src/test/scala/scala/async/run/match0/Match0.scala index 8b99214..49a3a69 100644 --- a/src/test/scala/scala/async/run/match0/Match0.scala +++ b/src/test/scala/scala/async/run/match0/Match0.scala @@ -13,6 +13,7 @@ import scala.async.Async.{async, await} import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.junit.Test +import scala.async.internal.AsyncId class TestMatchClass { diff --git a/src/test/scala/scala/async/run/nesteddef/NestedDef.scala b/src/test/scala/scala/async/run/nesteddef/NestedDef.scala index cf74602..409f70a 100644 --- a/src/test/scala/scala/async/run/nesteddef/NestedDef.scala +++ b/src/test/scala/scala/async/run/nesteddef/NestedDef.scala @@ -5,6 +5,7 @@ package nesteddef import org.junit.runner.RunWith import org.junit.runners.JUnit4 import org.junit.Test +import scala.async.internal.AsyncId @RunWith(classOf[JUnit4]) class NestedDef { diff --git a/src/test/scala/scala/async/run/noawait/NoAwaitSpec.scala b/src/test/scala/scala/async/run/noawait/NoAwaitSpec.scala index e2c69d0..ba9c9be 100644 --- a/src/test/scala/scala/async/run/noawait/NoAwaitSpec.scala +++ b/src/test/scala/scala/async/run/noawait/NoAwaitSpec.scala @@ -6,6 +6,7 @@ package scala.async package run package noawait +import scala.async.internal.AsyncId import AsyncId._ import org.junit.Test import org.junit.runner.RunWith diff --git a/src/test/scala/scala/async/run/toughtype/ToughType.scala b/src/test/scala/scala/async/run/toughtype/ToughType.scala index 2737132..ec2278f 100644 --- a/src/test/scala/scala/async/run/toughtype/ToughType.scala +++ b/src/test/scala/scala/async/run/toughtype/ToughType.scala @@ -13,6 +13,7 @@ import scala.async.Async._ import org.junit.Test import org.junit.runner.RunWith import org.junit.runners.JUnit4 +import scala.async.internal.AsyncId object ToughTypeObject { @@ -97,7 +98,7 @@ class ToughTypeSpec { } @Test def singletonTypeIssue17() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} class A { class B } async { val a = new A @@ -107,7 +108,7 @@ class ToughTypeSpec { } @Test def existentialMatch() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} trait Container[+A] case class ContainerImpl[A](value: A) extends Container[A] def foo: Container[_] = async { @@ -123,7 +124,7 @@ class ToughTypeSpec { } @Test def existentialIfElse0() { - import scala.async.AsyncId.{async, await} + import AsyncId.{async, await} trait Container[+A] case class ContainerImpl[A](value: A) extends Container[A] def foo: Container[_] = async { -- cgit v1.2.3