Skip to content

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

Merged
merged 5 commits into from
May 5, 2017

Conversation

OlivierBlanvillain
Copy link
Contributor

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! 🎉

@OlivierBlanvillain
Copy link
Contributor Author

OlivierBlanvillain commented Apr 27, 2017

I think productElement/productArity should be added in SyntheticMethods instead of desugaring.

Drone only caught that with legacyTests (test is passing), @felixmulder isn't this worrisome?

@felixmulder
Copy link
Contributor

Please investigate and add a meta test :)

@odersky
Copy link
Contributor

odersky commented Apr 27, 2017

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.
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
Copy link
Member

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.

Copy link
Contributor

@odersky odersky left a 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
Copy link
Contributor

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.

Copy link
Contributor Author

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?

@felixmulder felixmulder merged commit b1f5432 into scala:master May 5, 2017
@allanrenucci allanrenucci deleted the no-product-n branch December 14, 2017 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants