Skip to content

Print val for class parameters #4705

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 requested a review from liufengyun June 22, 2018 12:20
liufengyun
liufengyun previously approved these changes Jun 22, 2018
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

}
case _ =>
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Rename printArgDef to printParam? My impression is that param is used at definition site, arg is used usually used at calling site.

body.collectFirst {
case vdef @ ValDef(`name`, _, _) if vdef.flags.isParamAccessor =>
if (!vdef.flags.isLocal && !vdef.flags.isCaseAcessor)
this += "val " // TODO `var`s
Copy link
Contributor

Choose a reason for hiding this comment

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

More todos: access modifiers, default parameters, implicits.

@nicolasstucki nicolasstucki dismissed liufengyun’s stale review June 22, 2018 13:50

Add more code that needs review

@nicolasstucki
Copy link
Contributor Author

@liufengyun could you review the second commit

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

printedPrefix
}

def printFullClassName(tp: TypeOrBounds): Unit = {
Copy link
Contributor

Choose a reason for hiding this comment

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

TypeOrBounds -> Type? The same for the next line.

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, it is TypeOrBounds or more precisely Type | NoPrefix which is encoded as TypeOrBounds for scala2 compat

printedPrefix |= printProtectedOrPrivate(vdef)
if (vdef.flags.isMutable) this += "var "
else if (!printedPrefix && vdef.flags.isCaseAcessor) this // val not explicitly needed
else this += "val "
Copy link
Contributor

Choose a reason for hiding this comment

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

I would negate the second else if and put this += "val " as the body.

Copy link
Contributor

Choose a reason for hiding this comment

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

The name printedPrefix is not informative enough to understand the logic here.

var printedPrefix = false
if (vdef.flags.isOverride) {
this += "override "
printedPrefix = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Why skip val (line 641) if we have override?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We skip val if we have NOT override

@nicolasstucki nicolasstucki force-pushed the decompiled-print-constructor-vals branch from 5c48dfc to a62585c Compare June 22, 2018 16:02
@nicolasstucki nicolasstucki merged commit c225b1a into scala:master Jun 22, 2018
@Blaisorblade Blaisorblade deleted the decompiled-print-constructor-vals branch June 26, 2018 15:44
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