Add method unrolling to Scala 3
- Start: Oct/2024, End: Jan/2025
- 1 minute read
- all projects
Project URL this project is completed.
Summary: Enhance the Scala language to support binary compatible addition of parameters.
About the Project
Implement the specification of SIP-61, which specifies code generation of forwarder methods that match the signature of a method, before a parameter was added.
Current Status
The PR was approved by the SIP committee and Scala 3 maintainers, merging on January 27th 2025. It will be available as an experimental feature in Scala 3.7.0.
Done:
- ✅ New annotation
@scala.annotation.unroll
to enable the feature. - ✅ New phase after typechecking, before pickling, to generate forwarder methods.
- ✅ Detect correct usage of the annotation in prior "posttyper" phase.
- ✅ Lazy transform - only run transform where the annotation is used.
- ✅ Documentation page
- ✅ Report errors with incorrect usage.
- ✅ Detect problematic cases with transparent inline (where forwarders are not yet visible).
- ✅ Test edge cases such as incremental compilation.
- ✅ Test usage on
case class
,enum
,class
,trait
andobject
.
Final changes:
- ✅ based on feedback, added more tests, and redesigned the test suite to integrate better - including source file splitting depending on target platform.