-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove ProductN parent on case classes #2314
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
Conversation
I think productElement/productArity should be added in SyntheticMethods instead of desugaring. Drone only caught that with |
Please investigate and add a meta test :) |
I agree; it would be more logical to add the methods in SyntheticMethods. Indeed we do have code there that adds productArity. productElement is missing, though. |
This means the compiler needs to systematically synthesise productElement and productArity, which aligns with what scalac is doing. This change gets rid of last reference to scala.ProductN! 🎉
The implementation needed changes since Desugaring uses `untpd._` while SyntheticMethods uses `tpd._`. `productArity` is also removed from Desugaring, it's already implement in SyntheticMethods, so no changes there.
f5a7f6b
to
df39a40
Compare
val ioob = defn.IndexOutOfBoundsException.typeRef | ||
// That's not ioob.typeSymbol.primaryConstructor, this is the other one | ||
// that takes a String argument. | ||
val constructor = ioob.typeSymbol.info.decls.toList.tail.head.asTerm |
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.
It would be better if you didn't rely on the order of declarations and instead filtered the declarations to only include the one that you want.
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.
LGTM! Great to have this in.
// Second constructor of ioob that takes a String argument | ||
def filterStringConstructor(s: Symbol): Boolean = s.info match { | ||
case m: MethodType if s.isConstructor => m.paramInfos == List(defn.StringType) | ||
case _ => false |
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.
I think there's an easier way to get this, but I'll play with it and do it in a different PR.
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.
IndexOutOfBoundsException
contains two declarations, its primary constructor (which takes not argument), and this other constructor that takes a String. I first did .decls.toList.tail.head
, then changed it to this very precise filter, do you have something in between?
This means the compiler needs to systematically synthesise productElement and
productArity, which aligns with what scalac is doing.
This change gets rid of last reference to
scala.ProductN
! 🎉