Back to Typelevel
GSoC 2026

Compile-time Specialization for Scala 3 via Inline Traits

Specialization is a compiler transformation that optimizes generic program code such that code using primitive types can execute without significant overhead. The @specialized annotation in the Scala 2 programming language allowed programmers to direct the compiler to create optimized generic data structures for each primitive type. @specialized is used significantly in the implementation of high-performance Scala 2 libraries, allowing for performance without the productivity of generics. This optimization trades performance at the cost of extra space, as generic code must be specialized for each of the primitive types, scaling exponentially on the number of type parameters. Since the Scala 3 programming language has evolved significantly from Scala 2, the @specialized annotation is no longer available. This proposal will prototype a new scheme of specialization for the Scala 3 compiler based on inline traits that avoids the performance pitfalls of the Scala 2 implementation, enabling the evolution of many high-performance Scala 2 libraries into Scala 3.

Project details

Contributor

James You

Mentors

Not available

Technologies

Not listed in the archive