Skip to content

(draft) Change signature of macro-based chisel3.Bits.unary_~ to fix IntelliJ highlighting issue #4611

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

unkarjedy
Copy link

Hello, I am from the IntelliJ Scala Plugin team
We have an error report about ~ method not being resolved in IntelliJ with Scala Plugin:
https://youtrack.jetbrains.com/issue/SCL-15350/Operators-not-recognized-chisel3-library

The method is macro-based.
It declares to return Bits, but the macro substitutes it with UInt/ Boolean / SInt.
IntelliJ can't detect it because it knows nothing of the macro logic.

As I mentioned in the comment
There is a chance that this particular issue could be partially fixed by improving the method return type to use abstract type type Self <: Bits.

JFTR I know nothing about chisel details
It's a draft proposal, more for a discussion initiation...

Copy link

CLA Not Signed

@unkarjedy
Copy link
Author

Same with chisel3.Bits#<< it seems

@jackkoenig
Copy link
Contributor

Thanks for stopping by! We've know about this issue for a long time, but thought it was only fixable with an IntelliJ plugin or something. I think @sequencer might use a plugin for his team but generally speaking it's just been kind of lingering.

There is a chance that this particular issue could be partially fixed by improving the method return type to use abstract type type Self <: Bits.

If that works, that would be amazing, I don't use IntelliJ but if someone who does can confirm then I am happy to roll this approach out to all of the relevant methods.

@Emin017
Copy link
Contributor

Emin017 commented Jan 12, 2025

It works for me.
Without this fix:
before
After fix:
after-fix

IntelliJ IDEA 2024.3.1.1 (Ultimate Edition)
Scala Plugin Version: 2024.3.605

@jackkoenig
Copy link
Contributor

Thanks for confirming @Emin017!

I'll try to get to applying this fix soon across the board.

@sequencer
Copy link
Member

Sorry for the delay response:

I think @sequencer might use a plugin for his team but generally speaking it's just been kind of lingering.

However we only support fixing the D/I issue with https://github.com/chipsalliance/idealchisel/blob/master/idealchisel/src/InstanceInjector.scala
Personally, I am not inclined to modify the language for IDE support unless it does not impact the public API and passes the Mima check. In that case, I am entirely comfortable with the decision. Please leave this matter to Jack’s discretion.

On the contrary, we should consider implementing a Chisel whitebox plugin that enables the dynamic modification of return types using macros (which should be attributed to the Scala 2 implicit function design). I concur that we need to enhance my plugin; it is currently on my to-do list, and I am hiring a Scala full-time developer to work on it.

@unkarjedy
Copy link
Author

If you have questions while developing IJ plugin, you are welcome to ask them in our discord:
https://discord.com/channels/931170831139217469/931171260824707072

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants