-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix double execution in JSR223 Implementation #7010
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
I'm confused, what's the method that gets called twice exactly, and by whom ? Why is there a difference between scripting and non-scripting ? |
See in https://github.com/rjolly/dotty/blob/master/compiler/src/dotty/tools/repl/ScriptEngine.scala . In the eval method, first the method "run" is called, which at the end calls DisplayDefinitions which does a reflective method invocation (on something like |
How to reproduce:
|
The reason for this change is that currently, statements in the JSR223 script engine are evaluated twice. Once when the "run" method is called, and once when the value of the result is extracted. The first one needs not be, it exists solely due to displayDefinitions being called. If we put it behind a flag, the problem is solved.
@smarter Is there something I can do to help this PR going forward ? |
Very sorry about the delay, I'll try to review this properly this week! |
Is it alright to add a command line argument "repl-disable-display" ? The alternative is a constructor argument to ReplDriver, which is not perfect either. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally had time to look at this :). I think this is fine as is since it doesn't affect the code too much, but maybe in the future we could instead refactor ReplDriver slightly so you could override the method that run and print the definitions?
Thanks ! Yes, override would be fine, but indeed it requires some refactoring. I'll think about it. |
The reason for this change is that currently, statements in the
JSR223 script engine are evaluated twice. Once when the "run" method
is called, and once when the value of the result is extracted.
The first one needs not be, it exists solely due to displayDefinitions
being called. If we put it behind a flag, the problem is solved.