diff options
| author | Schuyler Eldridge | 2020-07-01 13:08:59 -0400 |
|---|---|---|
| committer | GitHub | 2020-07-01 17:08:59 +0000 |
| commit | 95bb2f66d34b40163c84c9c2893da50bd989e02f (patch) | |
| tree | 4b771e974afb0f146a3036777b3150144d76ca29 /src/main | |
| parent | cbfb32dc90f25c814898add3eff9b332b6021e5b (diff) | |
Fix unchecked type in ManipulateNames (#1726)
Fix a bug where a type check would always yield true. This caused a
bug where allow/block-list annotations would be incorrectly applied to
all subtypes of ManipulateNames.
The tests are updated to check that this now works.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/transforms/ManipulateNames.scala | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/main/scala/firrtl/transforms/ManipulateNames.scala b/src/main/scala/firrtl/transforms/ManipulateNames.scala index 956b39e6..c55dab57 100644 --- a/src/main/scala/firrtl/transforms/ManipulateNames.scala +++ b/src/main/scala/firrtl/transforms/ManipulateNames.scala @@ -432,14 +432,24 @@ abstract class ManipulateNames[A <: ManipulateNames[_] : ClassTag] extends Trans def execute(state: CircuitState): CircuitState = { val block = state.annotations.collect { - case ManipulateNamesBlocklistAnnotation(targetSeq, _: Dependency[A]) => targetSeq + case ManipulateNamesBlocklistAnnotation(targetSeq, t) => t.getObject match { + case _: A => targetSeq + case _ => Nil + } }.flatten.flatten.toSet - val allow = state.annotations.collect { - case ManipulateNamesAllowlistAnnotation(targetSeq, _: Dependency[A]) => targetSeq - } match { - case Nil => (a: Target) => true - case a => a.flatten.flatten.toSet + val allow = { + val allowx = state.annotations.collect { + case ManipulateNamesAllowlistAnnotation(targetSeq, t) => t.getObject match { + case _: A => targetSeq + case _ => Nil + } + }.flatten.flatten + + allowx match { + case Nil => (a: Target) => true + case a => a.toSet + } } val renames = RenameMap() @@ -447,11 +457,18 @@ abstract class ManipulateNames[A <: ManipulateNames[_] : ClassTag] extends Trans val annotationsx = state.annotations.flatMap { /* Consume blocklist annotations */ - case ManipulateNamesBlocklistAnnotation(_, _: Dependency[A]) => None - /* Convert allowlist annotations to result annotations */ - case ManipulateNamesAllowlistAnnotation(a, t: Dependency[A]) => (a, a.map(_.map(renames(_)).flatten)) match { - case (a, b) => Some(ManipulateNamesAllowlistResultAnnotation(b, t, a)) + case foo@ ManipulateNamesBlocklistAnnotation(_, t) => t.getObject match { + case _: A => None + case _ => Some(foo) } + /* Convert allowlist annotations to result annotations */ + case foo@ ManipulateNamesAllowlistAnnotation(a, t) => + t.getObject match { + case _: A => (a, a.map(_.map(renames(_)).flatten)) match { + case (a, b) => Some(ManipulateNamesAllowlistResultAnnotation(b, t, a)) + } + case _ => Some(foo) + } case a => Some(a) } |
