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

Disallow use of PolyFunction in user code #18920

Merged
merged 1 commit into from
Nov 23, 2023
Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Nov 14, 2023

The PolyFunction trait should only be used for compiler generated
encoded lambdas.

Any other use case that was allowed before was accidental. In the future,
we might consider supporting these if there is a good use case. This would
probably require a SIP.

Fixes #10075

@nicolasstucki nicolasstucki self-assigned this Nov 14, 2023
@nicolasstucki nicolasstucki changed the title Disallow use of PolyFunction trait in class parents Disallow use of PolyFunction in user code Nov 14, 2023
@nicolasstucki nicolasstucki force-pushed the fix-10075 branch 3 times, most recently from 2dddaf2 to 4ed7893 Compare November 15, 2023 07:10
@nicolasstucki nicolasstucki marked this pull request as ready for review November 15, 2023 11:59
@nicolasstucki nicolasstucki added the release-notes Should be mentioned in the release notes label Nov 15, 2023
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.

I think this might be too drastic, PolyFunction could come up in type inference for example (val x = if cond then polyFun1 else polyFun2), and if a type can be inferred it should be expressible whenever possible. An alternative I would favor would be to mark PolyFunction as @deprecatedInheritance.

@smarter smarter assigned nicolasstucki and unassigned smarter Nov 18, 2023
@smarter
Copy link
Member

smarter commented Nov 18, 2023

(I'm assuming we can tweak @deprecatedInheritance to not warn for poly function syntax, just explicit subclasses)

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Nov 20, 2023

We do not seem to be checking for deprecatedInheritance (see #19002).

@nicolasstucki
Copy link
Contributor Author

We could use the first commit (1b4b390) instead. This one only checks the parents of classes and does not restrict anything on types.

@smarter
Copy link
Member

smarter commented Nov 20, 2023

Using just the first commit sounds good to me.

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Nov 20, 2023

Using just the first commit sounds good to me.

Removed the second commit and rebased

@smarter smarter merged commit 00e9e6b into scala:main Nov 23, 2023
18 checks passed
@smarter smarter deleted the fix-10075 branch November 23, 2023 19:08
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes Should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

user defined anonymous PolyFunction causes crash at ElimPolyFunction, GenBCode
3 participants