-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Simplify decompiler printer for lambda #4255
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
Conversation
{ | ||
(x: Int) => 2.+(x).+(4) | ||
} | ||
(x: Int) => 2.+(x).+(4) |
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.
Could the result appear inside a "template" (class/trait)? Because then you sometimes do need parentheses around the closure to avoid (x: Int) =>
being parsed as a self-type declaration.
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.
Indeed, if one writes
class Test {
((x: Int) => x)
}
It will be pretty printed as
class Test() extends Object() {
(x: Int) => x
}
which will be parsed as a self type. But I do think the lightweight syntax is worth the newly introduced bug. One can fix the issue in a separate PR
tests/pos/lambda.decompiled
Outdated
@@ -3,10 +3,13 @@ out/posTestFromTasty/pos/lambda/foo/Foo.class | |||
-------------------------------------------------------------------------------- | |||
package foo { | |||
class Foo() extends Object() { |
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.
Needs a rebase. extends Object
is not printed anymore
} | ||
override protected def blockToText[T >: Untyped](block: Block[T]): Text = | ||
block match { | ||
case Block((meth @ DefDef(nme.ANON_FUN, _, _, _, _)) :: Nil, _: Closure[T]) => |
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.
Extract the RHS from the DefDef
(..., rhs)` directly.
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.
Should we extract the RHS using unapply
? We have something like this:
case class DefDef(..., private var preRhs: LazyTree) {
def rhs(implicit ctx) = forceIfLazy
}
I expect that the RHS should be accessed through def rhs
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.
Right
5804f92
to
2143728
Compare
No description provided.