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

Allow defining result type for local methods (needed for Scala 3 implicits) #594

Merged
merged 3 commits into from
Feb 26, 2023

Conversation

mkurz
Copy link
Member

@mkurz mkurz commented Feb 24, 2023

To define an implicit we need to prefix the name with implicit:

@implicitField = @{ ... }

this generates:

implicit def /*6.2*/implicitField = {{ ... }}

Scala 3 however complains:

[error] ./documentation/manual/working/javaGuide/main/forms/code/javaguide/forms/withFieldConstructor.scala.html:6:2:
[error]  result type of implicit definition needs to be given explicitly
[error] @implicitField = @{ ... }
[error]  ^

Until now it was not possible to define a result type, so this pull request adds support for that so we can now write:

@implicitField: FieldConstructor = @{ ... }

which generates:

implicit def /*6.2*/implicitField/*6.15*/:FieldConstructor = {{ ... }}

Works locally, tested with Play's Scala 3 pull requests, just needs some tests.

@mkurz mkurz force-pushed the resultType_localDef branch from 36ae933 to a9abeb2 Compare February 26, 2023 23:36
@mkurz
Copy link
Member Author

mkurz commented Feb 26, 2023

Added tests.

@mkurz mkurz merged commit 5c85092 into playframework:main Feb 26, 2023
@mkurz mkurz deleted the resultType_localDef branch February 26, 2023 23:47
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.

1 participant