Skip to content

Commit c9edfd0

Browse files
committed
draft attempt to fix highlighting issue in IntelliJ for Bits.unary_~
1 parent e12935e commit c9edfd0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

core/src/main/scala-2/chisel3/Bits.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ private[chisel3] sealed trait ToBoolable extends Element {
3737
*/
3838
sealed abstract class Bits(private[chisel3] val width: Width) extends BitsImpl with ToBoolable {
3939

40+
type Self <: Bits
41+
4042
/** Tail operator
4143
*
4244
* @param n the number of bits to remove
@@ -170,7 +172,7 @@ sealed abstract class Bits(private[chisel3] val width: Width) extends BitsImpl w
170172
* @return this $coll with each bit inverted
171173
* @group Bitwise
172174
*/
173-
final def unary_~ : Bits = macro SourceInfoWhiteboxTransform.noArg
175+
final def unary_~ : Self = macro SourceInfoWhiteboxTransform.noArg
174176

175177
/** @group SourceInfoTransformMacro */
176178
def do_unary_~(implicit sourceInfo: SourceInfo): Bits = _impl_unary_~
@@ -293,6 +295,7 @@ object Bits extends UIntFactory
293295
* @define constantWidth @note The width of the returned $coll is unchanged, i.e., `width of this`.
294296
*/
295297
sealed class UInt private[chisel3] (width: Width) extends Bits(width) with UIntImpl {
298+
type Self = UInt
296299

297300
// TODO: refactor to share documentation with Num or add independent scaladoc
298301
/** Unary negation (expanding width)
@@ -566,6 +569,7 @@ object UInt extends UIntFactory
566569
* @define constantWidth @note The width of the returned $coll is unchanged, i.e., `width of this`.
567570
*/
568571
sealed class SInt private[chisel3] (width: Width) extends Bits(width) with SIntImpl {
572+
override type Self = SInt
569573

570574
/** Unary negation (constant width)
571575
*
@@ -807,6 +811,8 @@ sealed class AsyncReset(private[chisel3] val width: Width = Width(1)) extends As
807811
* @define numType $coll
808812
*/
809813
sealed class Bool() extends UInt(1.W) with BoolImpl with Reset {
814+
//Compiler fails with error
815+
//override type Self = Bool
810816

811817
// REVIEW TODO: Why does this need to exist and have different conventions
812818
// than Bits?

0 commit comments

Comments
 (0)