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

Stabilise SIP-47 (Adding Clause Interleaving to method definitions) #20861

Merged
merged 3 commits into from
Jul 4, 2024

Conversation

hamzaremmal
Copy link
Member

Closes #20769

Initial implementation in #14019

@hamzaremmal hamzaremmal added the needs-minor-release This PR cannot be merged until the next minor release label Jun 28, 2024
@hamzaremmal hamzaremmal self-assigned this Jun 28, 2024
@hamzaremmal hamzaremmal force-pushed the i20769 branch 2 times, most recently from 6072739 to 7ff2398 Compare June 28, 2024 17:18
@hamzaremmal hamzaremmal marked this pull request as ready for review June 28, 2024 19:30
@hamzaremmal
Copy link
Member Author

hamzaremmal commented Jun 29, 2024

This PR is based on top of #20895

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

@@ -3878,13 +3878,11 @@ object Parsers {
val ident = termIdent()
var name = ident.name.asTermName
val paramss =
if in.featureEnabled(Feature.clauseInterleaving) then
// If you are making interleaving stable manually, please refer to the PR introducing it instead, section "How to make non-experimental"
if Feature.clauseInterleavingEnabled(using in.languageImportContext) then
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks out of line with other code that's version dependent, Why the using in.languageImportContext?
That's done nowhere else in the parser. Why not just the original test?

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a doc comment further up that needs to be updated.


     * if clauseInterleaving is enabled:
     *  DefSig  ::=  id [DefParamClauses] [DefImplicitClause]
     * 

As far as Parser is concerned, clauseInterleaving is now enabled, so the grammar should reflect this.

Copy link
Member Author

Choose a reason for hiding this comment

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

This looks out of line with other code that's version dependent, Why the using in.languageImportContext?
That's done nowhere else in the parser. Why not just the original test?

The issue there is that we also need to check if -source is configured and if it is less than 3.6, we should require the language import. While in.featureEnabled(Feature.clauseInterleaving) only checks that there is an import statement, it doesn't check the source version. Feature.clauseInterleavingEnabled does both of them but it seems that the context doesn't contain that information and the in.languageImportContext does (which is exactly what in.featureEnabled does)

@hamzaremmal
Copy link
Member Author

I will wait for #20895 to be merged before merging this PR

@@ -121,7 +121,8 @@ object Feature:

def namedTypeArgsEnabled(using Context) = enabled(namedTypeArguments)

def clauseInterleavingEnabled(using Context) = enabled(clauseInterleaving)
def clauseInterleavingEnabled(using Context) =
sourceVersion.isAtLeast(`3.6`) || enabled(clauseInterleaving)
Copy link
Member

@bishabosha bishabosha Jul 3, 2024

Choose a reason for hiding this comment

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

this shouldn't be mixing source version with language import checks, they should be kept separate,
e.g. in the parser do

if sourceVersion.isAtLeast(`3.6`) || in.featureEnabled(Feature.clauseInterleaving) then

Copy link
Member Author

@hamzaremmal hamzaremmal Jul 3, 2024

Choose a reason for hiding this comment

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

not sure to see why we should do that ?
edit: fewerBraces was stabilised in 3.3 and we do similarly:

def fewerBracesEnabled(using Context) =

Copy link
Member

Choose a reason for hiding this comment

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

ok, I guess its fine then, curious that in parser they just have Feature.fewerBracesEnabled without explicit using

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, I was currious too. I guess it might be a no-op as it is, therefore a bug ?

@hamzaremmal hamzaremmal merged commit 010ed5a into scala:main Jul 4, 2024
24 checks passed
@hamzaremmal hamzaremmal deleted the i20769 branch July 4, 2024 08:01
@Gedochao
Copy link
Contributor

Gedochao commented Jul 4, 2024

This has been decided to be included in the 3.6.0 release.

@SethTisue SethTisue changed the title Stabilise SIP-47 Stabilise SIP-47 (Adding Clause Interleaving to method definitions) Aug 7, 2024
@SethTisue
Copy link
Member

should #21195 be a blocker for this?

@sjrd
Copy link
Member

sjrd commented Aug 7, 2024

I don't think so. It only affects new code combined with Java code. It cannot break anyone immediately. We should fix it, though, for sure, but not a blocker IMO.

@SethTisue
Copy link
Member

okay, it was open as a discussion but I've made it into an issue, #21346

@WojciechMazur WojciechMazur added this to the 3.6.0 milestone Oct 8, 2024
@WojciechMazur WojciechMazur added the release-notes Should be mentioned in the release notes label Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-minor-release This PR cannot be merged until the next minor release release-notes Should be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stabilise SIP 47 - Clause Interleaving
7 participants