Skip to content

Commit

Permalink
Merge pull request #10419 from lrytz/t12723
Browse files Browse the repository at this point in the history
Avoid `-Wnonunit-statement` warning in synthetic code for async
  • Loading branch information
som-snytt committed Jun 23, 2023
2 parents 7db02fe + 2d61c8c commit ecbfb07
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class AsyncPhase extends Transform with TypingTransformers with AnfTran
method.updateAttachment(new AsyncAttachment(awaitMethod, postAnfTransform, stateDiagram, allowExceptionsToPropagate))
// Wrap in `{ expr: Any }` to force value class boxing before calling `completeSuccess`, see test/async/run/value-class.scala
deriveDefDef(method) { rhs =>
Block(Apply(gen.mkAttributedRef(definitions.Predef_locally), rhs :: Nil), Literal(Constant(())))
Block(Apply(gen.mkAttributedRef(definitions.Predef_locally), rhs :: Nil).updateAttachment(TypedExpectingUnitAttachment), Literal(Constant(())))
}.updateAttachment(ChangeOwnerAttachment(owner))
}

Expand Down
13 changes: 13 additions & 0 deletions test/async/run/t12723.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// scalac: -Xasync -Werror -Wnonunit-statement

import scala.tools.partest.async.OptionAwait._
import org.junit.Assert._

object Test {
def main(args: Array[String]): Unit = {
val r = optionally {
value(Some(true))
}
assert(r.get)
}
}

0 comments on commit ecbfb07

Please sign in to comment.