-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add tasty seal methods #5603
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
Add tasty seal methods #5603
Conversation
This does not include FunctionXXL
7ccacd2
to
46b815d
Compare
46b815d
to
761614c
Compare
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.
It is a great addition to support sealing methods as functions 🎉
val closureResType = mtpe.resType match { | ||
case t: MethodType => t.toFunctionType() | ||
case t => 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.
It seems this does handle param blocks > 2?
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.
It was working properly but did not fully convert to the lambda type. I changed toFunctionType
to make sure it never leaves MethodType
s as result type.
case 0 => pre.seal[() => Any].apply().unseal | ||
case 1 => pre.seal[Int => Any].apply('(0)).unseal | ||
case 2 => pre.seal[(Int, Int) => Any].apply('(0), '(0)).unseal | ||
case 3 => pre.seal[(Int, Int, Int) => Any].apply('(0), '(0), '(0)).unseal |
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.
If I understand correctly, this approach will create an unnecessary closure?
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.
It will create the extra closure, but when the apply is called directly on the seals expression it is beta reduced straight away.
Without this change we got types like `Int => (n: Int): Int`, now we get `Int => Int => Int`. The first type happened to work fine but is not consistent.
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 last commit LGTM
No description provided.