Skip to content

Removed all mkZero calls to fix #86 #90

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion src/main/scala/scala/async/internal/AnfTransform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private[async] trait AnfTransform {

private def defineVar(prefix: String, tp: Type, pos: Position): ValDef = {
val sym = api.currentOwner.newTermSymbol(name.fresh(prefix), pos, MUTABLE | SYNTHETIC).setInfo(uncheckedBounds(tp))
valDef(sym, gen.mkZero(uncheckedBounds(tp))).setType(NoType).setPos(pos)
valDef(sym, EmptyTree).setType(NoType).setPos(pos)
}
}

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 @@ -81,7 +81,7 @@ trait AsyncTransform {
List(
asyncBase.nullOut(c.universe)(c.Expr[String](Literal(Constant(fieldSym.name.toString))), c.Expr[Any](Ident(fieldSym))).tree
),
Assign(gen.mkAttributedStableRef(thisType(fieldSym.owner), fieldSym), gen.mkZero(fieldSym.info))
Assign(gen.mkAttributedStableRef(thisType(fieldSym.owner), fieldSym), EmptyTree)
)
}
val asyncState = asyncBlock.asyncStates.find(_.state == state).get
Expand Down
33 changes: 32 additions & 1 deletion src/test/scala/scala/async/run/toughtype/ToughType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,40 @@ class ToughTypeSpec {
val result = Await.result(f, 5.seconds)
result mustEqual (new IntWrapper("foo"))
}

@Test def ticket86NestedValueClass() {
import ExecutionContext.Implicits.global

val f = async {
val a = Future.successful(new IntWrapper("42"))
await(await(a).plusStr)
}
val result = Await.result(f, 5.seconds)
result mustEqual "42!"
}

@Test def ticket86MatchedValueClass(): Unit = {
import ExecutionContext.Implicits.global

def doAThing(param: IntWrapper) = Future(None)

val fut = async {
Option(new IntWrapper("value!")) match {
case Some(valueHolder) =>
await(doAThing(valueHolder))
case None =>
None
}
}

val result = Await.result(fut, 5.seconds)
result mustBe None
}
}

class IntWrapper(val value: String) extends AnyVal
class IntWrapper(val value: String) extends AnyVal {
def plusStr = Future.successful(value + "!")
}


trait A
Expand Down