Skip to content

Fix case class decompilation #4633

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

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@nicolasstucki nicolasstucki self-assigned this Jun 9, 2018
@nicolasstucki nicolasstucki force-pushed the fix-case-class-decompilation branch 3 times, most recently from d6f0dd3 to 820c3d8 Compare June 9, 2018 16:35
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM

tp match {
case Type.SymRef(cdef @ ClassDef(_, _, _, _, _), _) if !cdef.flags.isObject => this += ".this"
case _ => this
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why special case object here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When refering to the this type of a module we just refere directly to the module itself. For example scala.Predef and not scala.Predef.this.

@@ -112,8 +112,24 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
}
}

def keepDefinition(d: Definition): Boolean = {
val flags = d.flags
import flags._
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 import flags._ doesn't help in terms of readability: it takes me some time to realize that isParam is a method on d.flags. In isCaseUnOverridableMethod, it still uses d.flags.

A short doc can help better understand the motivation for the method isCaseUnOverridableMethod. A naive question: why not just ignore all synthetic definitions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will improve code and add docs.

I decided to print the synthetic methods to allow users to see what was generated. I will add some /* synthetic */ comment on them later. And I'm considering adding a mode that those not print them. I started printing them because I can test more code, therefore more of the Tasty reflect API.

@nicolasstucki nicolasstucki merged commit 35cf4a6 into scala:master Jun 10, 2018
@Blaisorblade Blaisorblade deleted the fix-case-class-decompilation branch June 15, 2018 16:45
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.

2 participants