-
Notifications
You must be signed in to change notification settings - Fork 600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Scala3] Redux: Convert cloneType to an extension method #4467
base: main
Are you sure you want to change the base?
Conversation
This removes much of the use of this.type in Chisel which is necessary to upgrade to Scala 3.
Can you explain more about why we need this? I know we saw errors related to it, but is there documentation or even a thread somewhere in Scala 3 development explaining the change? |
@jackkoenig updated the comment above with some more info |
@@ -558,7 +556,7 @@ private[chisel3] trait AsyncResetImpl extends Element { self: AsyncReset => | |||
|
|||
override def toString: String = stringAccessor("AsyncReset") | |||
|
|||
def cloneType: this.type = AsyncReset().asInstanceOf[this.type] | |||
override def _cloneType: Data = AsyncReset() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override def _cloneType: Data = AsyncReset() | |
override def _cloneType: AsyncReset = AsyncReset() |
? perhaps? Why is this one different than the others
@@ -13,7 +13,7 @@ private[chisel3] trait ClockImpl extends Element { | |||
|
|||
override def toString: String = stringAccessor("Clock") | |||
|
|||
def cloneType: this.type = Clock().asInstanceOf[this.type] | |||
override def _cloneType: Data = Clock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't this one Clock
?
|
||
implicit class DataExtensions[T <: Data](self: T) { | ||
|
||
/** Internal API; Chisel users should look at chisel3.chiselTypeOf(...). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an internal API, can we make it private to chisel?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
high level, why are we sometimes having the _cloneType
return type be Data and other times we are having the explicit type?
Redux of #3771. Turns out we need this for Scala3 after all
Ran into errors related to this while adding Scala3 cross-compilation support. Here's a sample of what an error with Dotty looks like:
I suspect this is due to the tightening of the type system in Scala3, specifically changes which make
this.type
a more stricter representation of the current instance. I think this SIP might have a more detailed specification of the related changes: https://docs.scala-lang.org/sips/42.type.html#related-scala-issues-resolved-by-the-literal-types-implementationContributor Checklist
docs/src
?Type of Improvement
Desired Merge Strategy
Release Notes
Move cloneType to an extension method in preparation for Scala3
Reviewer Checklist (only modified by reviewer)
3.6.x
,5.x
, or6.x
depending on impact, API modification or big change:7.0
)?Enable auto-merge (squash)
, clean up the commit message, and label withPlease Merge
.Create a merge commit
.