diff options
| author | Adam Izraelevitz | 2021-10-25 16:55:23 -0700 |
|---|---|---|
| committer | GitHub | 2021-10-25 23:55:23 +0000 |
| commit | 5024b706f0638cf3ebbe634b658fa016941e72ac (patch) | |
| tree | a8b0160f198d3185bc8b22a1891eb2a61e7fe5a3 /core/src/main/scala | |
| parent | d9722cd96159cd8957cd335d79dbb495260e590d (diff) | |
Bugfix: fix isACloneOf (#2205)
Diffstat (limited to 'core/src/main/scala')
| -rw-r--r-- | core/src/main/scala/chisel3/Module.scala | 13 | ||||
| -rw-r--r-- | core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/core/src/main/scala/chisel3/Module.scala b/core/src/main/scala/chisel3/Module.scala index 56dce4d5..1ae65969 100644 --- a/core/src/main/scala/chisel3/Module.scala +++ b/core/src/main/scala/chisel3/Module.scala @@ -193,7 +193,18 @@ package internal { // Underlying object of which this is a clone of val _proto: T def getProto: T = _proto - def isACloneOf(a: Any): Boolean = this == a || _proto == a + + /** Determines whether another object is a clone of the same underlying proto + * + * @param a + */ + def hasSameProto(a: Any): Boolean = { + val aProto = a match { + case x: IsClone[BaseModule] => x._proto + case o => o + } + this == aProto || _proto == aProto + } } // Private internal class to serve as a _parent for Data in cloned ports diff --git a/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala b/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala index b9617723..2242c1c4 100644 --- a/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala +++ b/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala @@ -217,7 +217,7 @@ private[chisel3] object Lookupable { } (m, context) match { case (c, ctx) if ctx == c => Left(c) - case (c, ctx: IsClone[_]) if ctx.isACloneOf(c) => Right(ctx.asInstanceOf[IsClone[A]]) + case (c, ctx: IsClone[_]) if ctx.hasSameProto(c) => Right(ctx.asInstanceOf[IsClone[A]]) case (c, ctx) if c._parent.isEmpty => Left(c) case (_, _) => cloneModuleToContext(Left(m._parent.get), context) match { |
