-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Warn or optimize when inline given inlines anonymous class creation #16723
Comments
This should already give a warning: #16499 |
Couldn't we automate this transformation? |
It also doesn't warn in the more general case that I gave in the first snippet. |
So this task's scope could be to transform every: inline given X[...] = new X {
def x1 = ...
// ...
def xn = ...
} to: inline given X[...] with
def x1 = ...
// ...
def xn = ... And treat the RHS function provided as implementation of trait as de facto first form, so transform it as well. But I wonder if assignment of explicit anonymous class and the |
Instead of doing the transformation, we could warn that |
I think that we should do the transformation for: inline given Conversion[Int, String] = _.toString() If the Conversion was defined instead as parametrized inline given Conversion[Int, String] = _.toString() vs inline given Conversion[Int, String] with
def apply(x: Int) = x.toString() Here the user msut acknowledge the implementation detail of Conversion - the In the other case, where user explicitly defines an anonymous class, the |
[Cherry-picked 8f84df8][modified]
I have this code that returns this warning and with -Werror makes my build fail.
I do not understand how I can fix it, if I try to create a class it will complain I cannot call
At the moment I had to add |
@ColOfAbRiX You'll get better feedback to your question by asking in one of https://scala-lang.org/community/ or opening a Discussion. |
Compiler version
3.2.1
Minimized example
Output
Creates 4 anon classes in the compilation output. Can lead to an explosion of amount of classes, killing the jit code cache (as seen in the lichess case)
Expectation
Should warn the User about the generation of anon classes per usage of Converter
inline given
, or find a way to avoid inlining anonymous class generation.The text was updated successfully, but these errors were encountered: