Skip to content

Print annotation in decompiler #4676

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 3 commits into from
Jun 18, 2018

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

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

printType(tree.tpe)
case tree @ Term.Ident(name) =>
tree.tpe match {
case Type.SymRef(_, Types.EmptyPrefix()) | Type.TermRef(_, Types.EmptyPrefix()) => this += name
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems SymRef subsumes TermRef?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, both are core.Types.NamedTypes but SymRef as a symbol as designator and TermRef has a TermName as designator.

@@ -768,13 +800,35 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
}

def printDefinitionName(sym: Definition): Buffer = sym match {
case ValDef(name, _, _) => this += name
case ValDef(name, _, _) => this += name += ".type"
Copy link
Contributor

Choose a reason for hiding this comment

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

why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm trying to figure out how to print (x: @annot), the issue is that it gets expanded to something like (x: x @annot). I was trying to workaround it by printing (x: x.type @annot) instead. I will now try to print it as (x: @annot) as it was originally.

@nicolasstucki nicolasstucki force-pushed the fix-decompiler-annots branch from 66fea8b to c5ff0b2 Compare June 18, 2018 11:23
@nicolasstucki
Copy link
Contributor Author

@liufengyun could you review the changes in the last commit

@nicolasstucki
Copy link
Contributor Author

@liufengyun last 2 commits

this += ".type"
case tpe => printType(tpe)
}
printTypeAndAnnots(tree.tpe)
Copy link
Contributor

Choose a reason for hiding this comment

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

tests/run-with-compiler/i3947c.scala failed due to the change, I cannot figure out why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was because scala.runtime.Null$ and scala.runtime.Nothing$ where handled as modules. Those are now special cases.

@nicolasstucki nicolasstucki force-pushed the fix-decompiler-annots branch from 7fa5814 to 40fffc1 Compare June 18, 2018 13:44
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.

LGTM

@nicolasstucki nicolasstucki merged commit 09e6599 into scala:master Jun 18, 2018
@liufengyun liufengyun deleted the fix-decompiler-annots branch June 18, 2018 15:29
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