Skip to content

Commit

Permalink
Restore BundleUpcastable (#3487) (#3494)
Browse files Browse the repository at this point in the history
(cherry picked from commit b904c19)

Co-authored-by: Jiuyang Liu <liu@jiuyang.me>
  • Loading branch information
mergify[bot] and sequencer authored Aug 16, 2023
1 parent 71b2521 commit 2bdf35d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/src/main/scala/chisel3/experimental/dataview/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ package object dataview {
}
}

/** Provides `viewAsSupertype` for subclasses of [[Bundle]] */
@deprecated("Use RecordUpcastable instead", "chisel3.6")
implicit class BundleUpcastable[T <: Bundle](target: T) {

/** View a [[Bundle]] or [[Record]] as a parent type (upcast) */
def viewAsSupertype[V <: Bundle](proto: V)(implicit ev: ChiselSubtypeOf[T, V], sourceInfo: SourceInfo): V = {
implicit val dataView = PartialDataView.supertype[T, V](_ => proto)
target.viewAs[V]
}
}

/** Provides `viewAsSupertype` for subclasses of [[Record]] */
implicit class RecordUpcastable[T <: Record](target: T) {

Expand Down

0 comments on commit 2bdf35d

Please sign in to comment.