Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,26 @@ private[hierarchy] object HierarchyLookupMacro {
)(using q: Quotes): (q.reflect.Symbol, q.reflect.TypeRepr) = {
import q.reflect.*
val tpe = TypeRepr.of[A]
val typeSym = tpe.typeSymbol
// For intersection types like `RawModule & HasProtocolInterface`,
// typeSymbol returns only one arm. Walk both arms so a @public
// field on either side can be resolved.
def classParts(t: TypeRepr): List[Symbol] = t.dealias match {
case AndType(l, r) => classParts(l) ::: classParts(r)
case other => List(other.typeSymbol)
}
val syms = classParts(tpe)
// Handle vals inherited from parent of an instance: fieldMember
// is declared in the Instance, while methodMember is the Scala 3
// representation of vals inherited from the parent
val fieldSym = typeSym.fieldMember(name) match {
case s if s != Symbol.noSymbol => s
case _ =>
typeSym.methodMember(name).find(_.paramSymss.flatten.isEmpty).getOrElse(Symbol.noSymbol)
val fieldSym = syms.iterator.map { typeSym =>
typeSym.fieldMember(name) match {
case s if s != Symbol.noSymbol => s
case _ =>
typeSym.methodMember(name).find(_.paramSymss.flatten.isEmpty).getOrElse(Symbol.noSymbol)
}
}
.find(_ != Symbol.noSymbol)
.getOrElse(Symbol.noSymbol)
if (fieldSym == Symbol.noSymbol) {
report.errorAndAbort(
s"value `$name` is not a member of ${tpe.show}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ class TestHarnessWithMonitorSocket[M <: RawModule with HasMonitorSocket](test: T
}

object TestHarnessWithMonitorSocket {
implicit def testharnessGenerator[M <: RawModule with HasMonitorSocket] =
implicit def testharnessGenerator[M <: RawModule with HasMonitorSocket]: TestHarnessGenerator[M] =
TestHarnessGenerator[M](new TestHarnessWithMonitorSocket(_))
}

@instantiable
trait HasMonitorSocket { this: RawModule =>
protected def makeProbe(bundle: ProtocolBundle): ProtocolBundle = {
val monProbe = IO(probe.Probe(chiselTypeOf(bundle)))
val monProbe = chisel3.IO(probe.Probe(chiselTypeOf(bundle)))
probe.define(monProbe, probe.ProbeValue(bundle))
monProbe
}
Expand Down Expand Up @@ -67,7 +67,7 @@ object ProtocolChecks {
}
}

trait HasTestsProperty { this: RawModule with HasTests =>
trait HasTestsProperty extends RawModule with HasTests {
def enableTestsProperty: Boolean

val testNames = Option.when(enableTestsProperty) {
Expand Down
Loading