Skip to content
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 polymorphic functions with erased parameters #18293

Merged
merged 1 commit into from
Jul 27, 2023

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Jul 26, 2023

This adds support for

[T1, ..., Tn] => ([erased] x1: X1, ..., [erased] xm: Xm) => r: R

Polymorphic function types with erased parameters are represented as using a refinement on PolyFunction. ErasedFunction is not needed.

PolyFunction {
  def apply[[T1, ..., Tn]]([given] [erased] x1: X1, ..., [erased] xm: Xm): R
}

@nicolasstucki nicolasstucki self-assigned this Jul 26, 2023
@nicolasstucki nicolasstucki force-pushed the poly-erased-functions branch 2 times, most recently from 11c0956 to 2fb1d1f Compare July 26, 2023 13:53
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I think we should also eventually drop ErasedFunction and only use PolyFunction for all refinements. /cc @natsukagami

@smarter
Copy link
Member

smarter commented Jul 26, 2023

One extra thing you might want to test is subtyping between lambda types, I assume (erased X) => Int and X => Int are not related by subtyping and the same holds for the polymorphic version.

This adds support for
```scala
[T1, ..., Tn] => ([erased] x1: X1, ..., [erased] xm: Xm) => R
```

Polymorphic function types with erased parameters are represented as
using a refinement on `PolyFunction`. `ErasedFunction` is not needed.
```scala
PolyFunction {
  def apply[T1, ..., Tn]([erased] x1: X1, ..., [erased] xm: Xm): R
}
```
@nicolasstucki nicolasstucki merged commit 182331b into scala:main Jul 27, 2023
17 checks passed
@nicolasstucki nicolasstucki deleted the poly-erased-functions branch July 27, 2023 06:57
@Kordyjan Kordyjan added this to the 3.4.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants