-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support signature polymorphic methods (MethodHandle
and VarHandle
)
#16225
Conversation
63acd79
to
7f9a0a7
Compare
@sjrd we were hoping you could review the TASTy changes |
MethodHandle
and VarHandle
)
c03c3cb
to
8cdf496
Compare
If you have to tweak the unpickler to get the newly pickled stuff to work, then it's still a breaking tasty change and will still require a minor release. Also I don't understand what the changes you're proposing to the unpickler do, so it's not clear to me if it's a better idea than adding a new tag? |
It's peaking through a Typed we added to get the result type, which together with the types of the arguments we can use to do the same symbol copying we do during typing, where we used the args and the prototype. At the meeting on Monday we discussed whether it was better to special case with a tag or special-case with existing constructs, and decided it might be good to do it without a new tag. |
Whether or not it's a new tag, it is new semantics in tasty that an existing reader (including earlier versions of the compiler) won't be able to read. So it must be a new minor version of tasty and of the compiler. Given that, you have a choice between:
I think it's pretty clear that the new tag is preferable. Moreover, I've been thinking about how this should be handled in tasty-query. I really don't want to create fake symbols, since that doesn't match a user's intuition about the language. Because of that, I think in tasty it would make more sense to have a dedicated |
71c6586
to
3ad35a8
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.
Very nice. IMO it's much better now :)
I have two comments which are more questions, really.
else if fun.symbol.originalSignaturePolymorphic.exists then | ||
writeByte(APPLYsigpoly) | ||
withLength { | ||
pickleTree(fun) |
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.
Shouldn't originalSignaturePolymorphic
be involved here, somehow?
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.
Like how? The function Select will be pickled as a SELECTin with the name "invokeExact" and the "in" as MethodHandle, which during unpickling will pick the original method and that's why we have to fix it up.
59cfa19
to
1b0b830
Compare
@sjrd Had to rebase this. Any chance you can give it a last look please? |
Yes, sorry. I will do that tomorrow afternoon. |
Will it get into 3.3.0-RC1? 👀 |
val mhOverI = l.findVirtual(classOf[Foo], "over", methodType(classOf[String], classOf[Int])) | ||
val mhUnit = l.findVirtual(classOf[Foo], "unit", methodType(classOf[Unit], classOf[String])) | ||
val mhObj = l.findVirtual(classOf[Foo], "obj", methodType(classOf[Any], classOf[String])) | ||
val mhCL = l.findStatic(classOf[ClassLoader], "getPlatformClassLoader", methodType(classOf[ClassLoader])) |
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.
This broke the CI because some of our jobs are running on Java 8 which does not define this method:
https://github.com/lampepfl/dotty/actions/runs/3524847656/jobs/5910798965
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.
blog post on this work: https://scala-lang.org/blog-detail/2023/07/17/signature-polymorphic-methods.html |
fixes #11332