Skip to content

Conversation

jackkoenig
Copy link
Contributor

This removes much of the use of this.type in Chisel which is necessary to upgrade to Scala 3.

There is still this.type used for other purposes:

  • suggestName
  • autoSeed
  • LitArg
  • ChiselEnum

I figure we can fix these in multiple IRs, this is the biggest one that is the most likely to cause breakages. While this is almost entirely source compatible, you may notice a few places I had to add this. in front of a cloneType. It will break any code where the user calls cloneType from within a Bundle or Record but leaves of the implicit this.. I'm not sure how big of an issue this is, we could potentially warn about it with the compiler plugin on 6.x.

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • API modification

Desired Merge Strategy

  • Squash

Release Notes

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
  • Did you mark the proper milestone (Bug fix: 3.6.x, 5.x, or 6.x depending on impact, API modification or big change: 7.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you do one of the following when ready to merge:
    • Squash: You/ the contributor Enable auto-merge (squash), clean up the commit message, and label with Please Merge.
    • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

This removes much of the use of this.type in Chisel which is necessary
to upgrade to Scala 3.
@jackkoenig jackkoenig added API Modification Scala 3 Changes related to upgrading to Scala 3 labels Jan 27, 2024
@jackkoenig jackkoenig added this to the 7.0 milestone Jan 27, 2024
@jackkoenig
Copy link
Contributor Author

I also may be entirely wrong about this.type in Scala 3. I tried adding -Xsource:3 and didn't notice any errors from this.type so I tried using it in Scala3 and it seems to work...? https://scastie.scala-lang.org/dxX1lfOYQHSmYTTjHgcQEg

@mwachs5
Copy link
Contributor

mwachs5 commented Jan 28, 2024

That example compiles but isn't actually exercising anything but the .tostring? I changed the tostring and the message changed. Not sure what you are trying to show in the example?

@jackkoenig
Copy link
Contributor Author

As far as I can tell, this isn't actually needed for Scala 3 so I am going to close this. We may still want to make this change eventually, but it's a separate discussion from preparing the codebase for Scala 3 support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Modification Scala 3 Changes related to upgrading to Scala 3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants