-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Print val
for class parameters
#4705
Conversation
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.
Otherwise, LGTM
} | ||
case _ => | ||
} | ||
|
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.
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 |
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.
More todos: access modifiers, default parameters, implicits.
Add more code that needs review
@liufengyun could you review the second commit |
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.
Otherwise, LGTM
printedPrefix | ||
} | ||
|
||
def printFullClassName(tp: TypeOrBounds): Unit = { |
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.
TypeOrBounds
-> Type
? The same for the next line.
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.
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 " |
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 would negate the second else if
and put this += "val "
as the body.
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.
The name printedPrefix
is not informative enough to understand the logic here.
var printedPrefix = false | ||
if (vdef.flags.isOverride) { | ||
this += "override " | ||
printedPrefix = true |
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.
Why skip val
(line 641) if we have override
?
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.
We skip val
if we have NOT override
5c48dfc
to
a62585c
Compare
No description provided.