From 993ee4ed8b95e2c78f6fc54ecbd828ac06a32b8b Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Wed, 22 Jan 2020 14:03:47 -0500 Subject: Change when/switch thunk type to Any (#1308) * Change when thunks return type to Any Changes the type of the thunk for when and WhenContext methods from call-by-name Unit to call-by-name Any. This prevents a warning (-Ywarn-value-discard) where a when thunk is returning something other than Unit that is then discarded, e.g., another WhenContext. Signed-off-by: Schuyler Eldridge * Change switch thunk return to type to Any Changes the type of switch thunks from call-by-name Unit to call-by-name Any. This prevents a warning (-Ywarn-value-discard) when the internals of a switch block return something other than Unit which is then discarded. Signed-off-by: Schuyler Eldridge --- chiselFrontend/src/main/scala/chisel3/When.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'chiselFrontend') diff --git a/chiselFrontend/src/main/scala/chisel3/When.scala b/chiselFrontend/src/main/scala/chisel3/When.scala index 50e13a1f..ea243bbe 100644 --- a/chiselFrontend/src/main/scala/chisel3/When.scala +++ b/chiselFrontend/src/main/scala/chisel3/When.scala @@ -28,7 +28,7 @@ object when { // scalastyle:ignore object.name * }}} */ - def apply(cond: => Bool)(block: => Unit)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { // scalastyle:ignore line.size.limit + def apply(cond: => Bool)(block: => Any)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { // scalastyle:ignore line.size.limit new WhenContext(sourceInfo, Some(() => cond), block) } } @@ -43,7 +43,7 @@ object when { // scalastyle:ignore object.name * succeeding elsewhen or otherwise; therefore, this information is * added by preprocessing the command queue. */ -final class WhenContext(sourceInfo: SourceInfo, cond: Option[() => Bool], block: => Unit, firrtlDepth: Int = 0) { +final class WhenContext(sourceInfo: SourceInfo, cond: Option[() => Bool], block: => Any, firrtlDepth: Int = 0) { /** This block of logic gets executed if above conditions have been * false and this condition is true. The lazy argument pattern @@ -51,7 +51,7 @@ final class WhenContext(sourceInfo: SourceInfo, cond: Option[() => Bool], block: * declaration and assignment of the Bool node of the predicate in * the correct place. */ - def elsewhen (elseCond: => Bool)(block: => Unit)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { // scalastyle:ignore line.size.limit + def elsewhen (elseCond: => Bool)(block: => Any)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): WhenContext = { // scalastyle:ignore line.size.limit new WhenContext(sourceInfo, Some(() => elseCond), block, firrtlDepth + 1) } @@ -62,7 +62,7 @@ final class WhenContext(sourceInfo: SourceInfo, cond: Option[() => Bool], block: * assignment of the Bool node of the predicate in the correct * place. */ - def otherwise(block: => Unit)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = + def otherwise(block: => Any)(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Unit = new WhenContext(sourceInfo, None, block, firrtlDepth + 1) /* -- cgit v1.2.3