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

Script parser preserves target module #10563

Draft
wants to merge 1 commit into
base: 2.13.x
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Oct 12, 2023

Fixes scala/bug#12889

Allow adding main to an existing object.

It takes a prefix of top-level statements which remain top-level (which helps with any issues with local methods).

If the "target" module was already defined at the "bottom of the file", so that it winds up in the "main" method, then also synthesize a call to its existing main method or just initialize the lazy object if there is no main method. [TODO]

@scala-jenkins scala-jenkins added this to the 2.13.13 milestone Oct 12, 2023
@lrytz lrytz modified the milestones: 2.13.13, 2.13.14 Nov 29, 2023
@som-snytt som-snytt marked this pull request as ready for review January 27, 2024 21:48
@som-snytt
Copy link
Contributor Author

I tried reviewing this and now I can't stop yawning.

@lrytz lrytz requested a review from SethTisue January 29, 2024 14:55
@SethTisue
Copy link
Member

SethTisue commented Jan 29, 2024

Is the TODO in the PR description still a TODO? (And for this PR, or for some hypothetical future PR?)

@som-snytt
Copy link
Contributor Author

🥱

I believe that todo was aspirational, in the medical sense of

Aspiration is when something you swallow "goes down the wrong way" and enters your airway (trachea or windpipe) or lungs.

trying to snack while yawning uncontrollably.

@SethTisue
Copy link
Member

SethTisue commented Jan 29, 2024

@som-snytt I'm going to go into schoolmarm mode here and say: I'm not sure I understand you, and also, this isn't only about it's about whether I personally understand. For the PR to be considered ready for review, can you edit the PR description to reflect the current state, as clearly as you possibly can? It's generally okay to be more freewheeling in our back-and-forth in the comments, but PR descriptions are documentation.

@som-snytt
Copy link
Contributor Author

som-snytt commented Jan 29, 2024

Yes, I'll get back to this before 2.13.14!

Edit: oh, I see I marked it ready for review. Maybe I wanted feedback on whether it's worth trying for 2.13.13, but it's not critical; it's just a nuisance when testing code snippets.

@som-snytt som-snytt marked this pull request as draft January 29, 2024 19:45
@SethTisue
Copy link
Member

Yeah, offhand I'd say this looks eventually-mergeable, but 2.13.14 would be fine.

@SethTisue SethTisue removed their request for review January 31, 2024 19:05
@SethTisue SethTisue modified the milestones: 2.13.14, 2.13.15 Mar 13, 2024
@som-snytt som-snytt closed this Mar 20, 2024
@SethTisue SethTisue removed this from the 2.13.15 milestone Mar 21, 2024
@som-snytt som-snytt reopened this Apr 15, 2024
@scala-jenkins scala-jenkins added this to the 2.13.15 milestone Apr 15, 2024
@som-snytt
Copy link
Contributor Author

I needed this today. Ticket has

object Bug {
  def main(args: Array[String]): Unit = {
    sealed trait Step {

but Bug is rewritten to Main. Just run the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants