From a352b24ebe6a74b20ffb6b8c5aa6bc6eb3a415ba Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 8 Jan 2015 10:52:52 +1000 Subject: [PATCH 1/3] Bump to 0.9.4-SNAPSHOT --- README.md | 4 ++-- build.sbt | 2 +- release.sh | 34 ---------------------------------- 3 files changed, 3 insertions(+), 37 deletions(-) delete mode 100755 release.sh diff --git a/README.md b/README.md index ca00ad29..62c6b4f7 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Add a dependency: ```scala // SBT -libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.9.2" +libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.9.3" ``` Write your first `async` block: @@ -145,6 +145,6 @@ difficult to understand. - See the [neg](https://github.com/scala/async/tree/master/src/test/scala/scala/async/neg) test cases for for constructs that are not allowed in a async block - See the [issue list](https://github.com/scala/async/issues?state=open) for which of these restrictions are planned - to be dropped in the next milestone. + to be dropped. - See [#13](https://github.com/scala/async/issues/13) for why `await` is not possible in closures, and for suggestions on ways to structure the code to work around this limitation. diff --git a/build.sbt b/build.sbt index c151ee54..0fdaa7ab 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ organization := "org.scala-lang.modules" name := "scala-async" -version := "0.9.3-SNAPSHOT" +version := "0.9.4-SNAPSHOT" libraryDependencies <++= (scalaVersion) { sv => Seq( diff --git a/release.sh b/release.sh deleted file mode 100755 index 89964ac1..00000000 --- a/release.sh +++ /dev/null @@ -1,34 +0,0 @@ -#! /bin/bash -e -# -# Build, test, and release Scala Async. -# -# Requires credentials: -# -# % cat ~/.sbt/0.13/publish.sbt -# credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", "", "") -# -# Also requires the sbt-pgp plugin installed globally to provide the `publishSigned` command. -# -# % cat ~/.sbt/0.13/plugins/gpg.sbt -# addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1") - -die () { - echo "$@" - exit 1 -} - -CHECK=";clean;test;publishLocal" -RELEASE=";clean;test;publishSigned" -VERSION=`gsed -rn 's/version :=.*"(.+).*"/\1/p' build.sbt` -[[ -n "$(git status --porcelain)" ]] && die "working directory is not clean!" - -sbt $CHECK -sbt $RELEASE - -cat < Date: Mon, 6 Jul 2015 12:45:08 +1000 Subject: [PATCH 2/3] Update README.md --- README.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 62c6b4f7..6e752baf 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,8 @@ -# Scala Async Project - -[![Build Status](https://secure.travis-ci.org/scala/async.png)](http://travis-ci.org/scala/async) - +# scala-async [](https://travis-ci.org/scala/async) [](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-async_2.10) [](http://search.maven.org/#search%7Cga%7C1%7Cg%3Aorg.scala-lang.modules%20a%3Ascala-async_2.11*) ## Quick start -Add a dependency: - -```scala -// SBT -libraryDependencies += "org.scala-lang.modules" %% "scala-async" % "0.9.3" -``` - -Write your first `async` block: +After adding a scala-async to your classpath, write your first `async` block: ```scala import ExecutionContext.Implicits.global From 953414f53691ee4e0d9a34d304a0ebef60ce68f6 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 6 Jul 2015 12:23:52 +1000 Subject: [PATCH 3/3] Fix compiler crash with value class in result position We were leaking untyped trees out of the macro, which crashed in refchecks. This commit proactively typechecks the tree returned by `mkZero`. (cherry picked from commit f4275e22e000541eb619808723b70bd64b9b4873) --- .../scala/scala/async/internal/TransformUtils.scala | 5 +++-- .../scala/scala/async/run/toughtype/ToughType.scala | 13 +++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/scala/scala/async/internal/TransformUtils.scala b/src/main/scala/scala/async/internal/TransformUtils.scala index 0b8cd008..da76c18e 100644 --- a/src/main/scala/scala/async/internal/TransformUtils.scala +++ b/src/main/scala/scala/async/internal/TransformUtils.scala @@ -259,10 +259,11 @@ private[async] trait TransformUtils { if (tp.typeSymbol.isDerivedValueClass) { val argZero = mkZero(tp.memberType(tp.typeSymbol.derivedValueClassUnbox).resultType) val target: Tree = gen.mkAttributedSelect( - typer.typedPos(macroPos)( + callSiteTyper.typedPos(macroPos)( New(TypeTree(tp.baseType(tp.typeSymbol)))), tp.typeSymbol.primaryConstructor) val zero = gen.mkMethodCall(target, argZero :: Nil) - gen.mkCast(zero, tp) + // restore the original type which we might otherwise have weakened with `baseType` above + callSiteTyper.typedPos(macroPos)(gen.mkCast(zero, tp)) } else { gen.mkZero(tp) } diff --git a/src/test/scala/scala/async/run/toughtype/ToughType.scala b/src/test/scala/scala/async/run/toughtype/ToughType.scala index 0f56ae09..ec59399d 100644 --- a/src/test/scala/scala/async/run/toughtype/ToughType.scala +++ b/src/test/scala/scala/async/run/toughtype/ToughType.scala @@ -286,6 +286,19 @@ class ToughTypeSpec { val result = Await.result(fut, 5.seconds) result mustBe None } + + // https://github.com/scala/async/issues/106 + @Test def valueClassT106(): Unit = { + import scala.async.internal.AsyncId._ + async { + "whatever value" match { + case _ => + await("whatever return type") + new IntWrapper("value class matters") + } + "whatever return type" + } + } } class IntWrapper(val value: String) extends AnyVal {