Skip to content

Fix compiler crash with value class in result position #108

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
Jul 6, 2015
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
5 changes: 3 additions & 2 deletions src/main/scala/scala/async/internal/TransformUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
13 changes: 13 additions & 0 deletions src/test/scala/scala/async/run/toughtype/ToughType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down