Skip to content

Commit

Permalink
Support using switch without importing SwitchContext (bp #1595) (#1597)
Browse files Browse the repository at this point in the history
* Support using switch without importing SwitchContext (#1595)

(cherry picked from commit 9c4f14f)

# Conflicts:
#	docs/src/wiki-deprecated/cookbook.md

* Resolve merge conflicts

Co-authored-by: Jack Koenig <koenig@sifive.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
mergify[bot] and jackkoenig authored Nov 11, 2020
1 parent eb425f6 commit aae0ba9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/scala/chisel3/util/Conditional.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ object switch { // scalastyle:ignore object.name
def apply[T <: Element](cond: T)(x: => Any): Unit = macro impl
def impl(c: Context)(cond: c.Tree)(x: c.Tree): c.Tree = { import c.universe._
val q"..$body" = x
val res = body.foldLeft(q"""new SwitchContext($cond, None, Set.empty)""") {
val res = body.foldLeft(q"""new chisel3.util.SwitchContext($cond, None, Set.empty)""") {
case (acc, tree) => tree match {
// TODO: remove when Chisel compatibility package is removed
case q"Chisel.`package`.is.apply( ..$params )( ..$body )" => q"$acc.is( ..$params )( ..$body )"
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/chiselTests/SwitchSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package chiselTests

import chisel3._
import chisel3.stage.ChiselStage
import chisel3.util._
import chisel3.util.{switch, is}

class SwitchSpec extends ChiselFlatSpec with Utils {
"switch" should "require literal conditions" in {
Expand Down

0 comments on commit aae0ba9

Please sign in to comment.