Skip to content

Commit ae6bab6

Browse files
committed
wip
1 parent 19e0c55 commit ae6bab6

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

_posts/2023-00-00-signature-polymorphic-methods.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ classes.
7979

8080
## What does "signature polymorphism" mean, exactly?
8181

82-
As the [Javadoc for `MethodHandle`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/invoke/MethodHandle.html) says,
82+
There is a formal description in [JLS 15.12.3](), but a more readable
83+
version is in the [Javadoc for
84+
`MethodHandle`](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/invoke/MethodHandle.html).
85+
It says:
8386

8487
> A signature polymorphic method is one which can operate with any of
8588
> a wide range of call signatures and return types.
@@ -106,6 +109,8 @@ type parameters.
106109

107110
The following example should help make all of this clearer.
108111

112+
* [JLS 15.12.3]: https://docs.oracle.com/javase/specs/jls/se17/html/jls-15.html#jls-15.12.3
113+
109114
## How do I call a signature polymorphic method from Scala?
110115

111116
Take `MethodHandle` for example. It provides an `invokeExact`
@@ -189,9 +194,9 @@ request](https://github.com/lampepfl/dotty/pull/16225).
189194

190195
### The path not taken
191196

192-
Along the way we explored an alternative approach, suggested by Jason
193-
Zaugg, which involved rewriting each call site to include a
194-
cast to a structural type containing an appropriately typed method.
197+
Along the way we explored an alternative approach, suggested by Jason,
198+
which involved rewriting each call site to include a cast to a
199+
structural type containing an appropriately typed method.
195200

196201
In that version, the `replace` call-site in the example above was
197202
rewritten from:
@@ -226,17 +231,3 @@ complicated the implementation.
226231
These are welcome on the Scala Contributors forum thread at:
227232

228233
* (TODO Discourse link, with link back to this post)
229-
230-
> TODO: include a link to the relevant section of the JLS
231-
232-
> TODO: find the JEP and any design discussions;
233-
> VarHandle JEP https://openjdk.org/jeps/193
234-
> hmm wait, did MethodHandle actually land in JDK 7?
235-
> yes! https://docs.oracle.com/javase/7/docs/api/java/lang/invoke/MethodHandle.html
236-
> references signature polymorphism
237-
238-
> TODO: link to something that explains what Java reflection even is?
239-
240-
> TODO:
241-
> cover the type ascription vs cast design issue?
242-
> (Java has casts, in Scala type ascription is more idiomatic)?

0 commit comments

Comments
 (0)