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

Check user defined PolyFunction refinements #18457

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Aug 25, 2023

Fixes #8299
Fixes #18302

traverseChildren(tree)

def reportNoRefinements(pos: SrcPos) =
report.error("PolyFunction refinement must have a refinements of the apply method", pos)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
report.error("PolyFunction refinement must have a refinements of the apply method", pos)
report.error("PolyFunction subtypes must refine the apply method", pos)

`PolyFunction` must be refined with an `apply` method that has a single
parameter list with no by-name nor varargs parameters. It may optionally
have type parameters. Some of these restrictions could be lifted later,
but for now these features are not properly handled by the compiler.

Fixes scala#8299
Fixes scala#18302
@nicolasstucki nicolasstucki merged commit 12a373f into scala:main Oct 12, 2023
16 checks passed
@nicolasstucki nicolasstucki deleted the fix-18302 branch October 12, 2023 16:16
@Kordyjan Kordyjan added this to the 3.4.0 milestone Dec 20, 2023
@xuwei-k
Copy link
Contributor

xuwei-k commented Dec 23, 2023

😢

Welcome to Scala 3.4.0-RC1 (1.8.0_392, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                                                             
scala> val x = [a] => (b: a) => b
val x: [a] => (b: a) => a = Lambda$1345/1620368915@5d1bdd4a
                                                                                                                                             
scala> x: PolyFunction
java.lang.ClassCastException: rs$line$1$$$Lambda$1345/1620368915 cannot be cast to scala.PolyFunction
  ... 35 elided

WojciechMazur added a commit that referenced this pull request Jun 20, 2024
Backports #18457 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
WojciechMazur added a commit that referenced this pull request Jun 20, 2024
Backports #18457 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
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.

Invalid PolyFunction refinements explicit "PolyFunction" type annotation cause ClassCastException
4 participants