Inline Traits for Specialization

Session Abstract

Inline traits are a language feature that eliminate allocations and virtual dispatch associated with trait composition in Scala. They do so by inlining their methods into their implementing subclasses. When inline traits are combined with the Specialized type class, they enable trait-based abstractions to be zero-cost.

Session Description

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 talk will briefly describe a new scheme of specialization for the Scala 3 compiler based on inline traits.

Kesselhaus
12.Oct 2026
12:30pm - 12:35pm
Lightning Talk
James You
James You

PhD Student

University of Waterloo