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
feature req: specialized singleton types and valueOf #11489
Comments
labeled as "good first issue" not because I'm already confident it's easily solvable, but because a newcomer could at least investigate |
Does it make sense to have a new type match on |
@SethTisue :I am new to handle this issue, I tried to add specialized annotation to ValueOf class, but failed, could you give me some hint about this, thank you |
@chenghsienwen where did you get stuck? what changes did you make, what was the resulting error message or unexpected behavior...? |
@SethTisue what changes did you make: |
@chenghsienwen okay, so we've learned that it's not as simple as just adding the annotation. have you investigated any further? do you have any hypothesis about why you're still getting that error message, or what further changes might be needed...? if you want to pursue this further, you'll need to dig deeper. |
Thank you for advise, I will let it be and proceed others good first issue |
I have conducted some tests on this, hoping to advance the problem. I'm a novice. There may be some inaccuracies.
So it will true when Obviously, As above, the constructor's parameters are not used to handle this. Only type parameters were used. Change to the following, feasible? if (tp.isSpecialized || arg.typeSymbol.isSpecialized) .... |
it's been so long since significant work has been done on specialization that there may not be anybody available who can answer your question. perhaps PR it and let's see if the tests pass? |
Yes. I have this plan. |
I see this ticket got a number of thumbs up. It would be helpful if y'all (and/or @lJoublanc himself) could try the PR out and see if it works with whatever use cases you had in mind: scala/scala#10165 The PR validation snapshot is testable with:
|
The constraint type of the type parameter supports specialization, and there are `specialized` annotation. It should support specialization. scala/bug#11489
@SethTisue Although the PR has been submitted and passed the test, after careful investigation, it is regrettable to explain again that since the type parameter of ValueOf cannot be added with specialization annotations, the generation of specialization methods alone cannot reduce unpacking. NO PR: jvm code
def twice(implicit evidence$1: Integer): Int = scala.Int.unbox(scala.Predef.valueOf(evidence$1)).*(2);
After PR: jvm code
<specialized> def twice$mIc$sp(evidence$1: Integer): Int = scala.Int.unbox(scala.Predef.valueOf(evidence$1)).*(2); On the other hand, in order to reduce unpacking, there are two ways: modify the
Then we will get : <specialized> def twice$mIc$sp(evidence$1: Integer): Int = scala.Predef.valueOf$mIc$sp(evidence$1).*(2); After adding |
Using 2.13-M5, it's not possible to specialize singleton types.
I think this is because
ValueOf
is not specialized.In my program I can see lots of boxing in a heap trace.
It would be nice if this could indeed be specialized for the primitive types such as
Int
,Double
etc.The text was updated successfully, but these errors were encountered: