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

Make object wrapper extend App #2556

Merged
merged 11 commits into from
Nov 20, 2023

Conversation

MaciejG604
Copy link
Contributor

@MaciejG604 MaciejG604 commented Nov 16, 2023

Fixes #2470

Thanks to @rochala for suggesting the solution of using a wrapper that extends App.

This simple fix seems to have been overlooked in the past, probably because it has some quirks when it comes to different Scala versions.

For Scala 2.12 and 2.13 an object that extends App avoids the deadlock when background threads are started from its initialization clause.
However, this is not true for Scala 3, it is a known bug that has not been fixed yet - scala/scala3#16149


RESTRICTIONS of the new wrapper:

  • scripts named main.sc can't be accessed from other scripts that use the App wrapper since the name main clashes with their main method.

@MaciejG604 MaciejG604 force-pushed the make-object-wrapper-extend-app branch from bd45387 to 1c63f76 Compare November 16, 2023 16:27
@MaciejG604 MaciejG604 force-pushed the make-object-wrapper-extend-app branch from 1c63f76 to 117d695 Compare November 17, 2023 10:18
@MaciejG604 MaciejG604 force-pushed the make-object-wrapper-extend-app branch 2 times, most recently from a871cc7 to 7c175d7 Compare November 17, 2023 12:16
@MaciejG604 MaciejG604 force-pushed the make-object-wrapper-extend-app branch 2 times, most recently from 97a4e2a to bf86276 Compare November 17, 2023 15:41
@MaciejG604 MaciejG604 requested a review from Gedochao November 20, 2023 08:30
@MaciejG604 MaciejG604 marked this pull request as ready for review November 20, 2023 08:34
@MaciejG604 MaciejG604 force-pushed the make-object-wrapper-extend-app branch from bf86276 to 966431f Compare November 20, 2023 08:39
Copy link
Contributor

@Gedochao Gedochao left a comment

Choose a reason for hiding this comment

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

LGTM, very cool hack

Co-authored-by: Piotr Chabelski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

scala-cli stalls when awaiting every single result from a list of Futures.
2 participants