-
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
inline def apply
throws unhandled exception
#19724
Comments
It works if class does not inherit from object repro:
// works when Mapper does not extend A=>B
abstract class Mapper[A, B]:
def apply(a: A): B
given Mapper[Int, Double] with
inline def apply(v: Int): Double = v.toDouble |
Minimizationclass MyMapper extends (Int => Double):
inline def apply(v: Int): Double = v.toDouble |
It seems there is a buggy interaction between function specialization and retained inlines. exception while retyping
class MyMapper() extends Object(), (Int => Double) {
inline def apply(v: Int): Double = this.apply$mcDI$sp(v)
inline def apply$mcDI$sp(v: Int): Double = v.toDouble:Double
private def apply$retainedBody(v: Int): Double = v.toDouble:Double
} |
We probably need to generate an |
We also do not need to specialize the inline version of the method. |
This issue was picked for the Issue Spree of Februrary 27th, 2024. @nicolasstucki, @EugeneFlesselle, @SethTisue and @nmcb will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here. |
As far as we can see, this is as simple as adding an This change isn't actually necessary to fix the bug, as the extra specialized method ends up disappearing during erasure anyway, but I agree it's worth doing while we're messing with this. |
As for the main change, this will also be in It's a bit complicated because of the way the We are provisionally thinking that to be consistent with the handling of non-specialized inline methods, it seems best to generate |
Heh, we're already second-guessing this, as it seems that erasure ( |
A tricky bit here is that the body of the unspecialized version of Do we need to back up and rethink? |
I'm not able to summarize the remaining twists and turns the work took, but Nico's PR will show where this ended up. Besides looking at the code, the other best way to understand how it works is to compile the test case with Scala 3 also specializes tuples, but we don't see any way for this issue to arise there, since tuples are final. |
I refactored the solution to do all the work in |
Compiler version
3.4.0-RC2
Minimized code
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: