Migrating Tuples (Kotlin M3 and Higher)

Tuple types and expression are no longer supported in Kotlin starting from M3. Data classes are the preferred way of dealing with tuple-like data. Library classes Pair and Triple are available for respective purposes.

If you have some code that uses tuples, written in earlier versions of Kotlin, you can migrate automatically using a quick-fix available in IntelliJ IDEA plugin for Kotlin, version M3.

Tuple types and expressions will be highlighted as errors in your code, a quick-fix is available on the errors for tuples of length 0 through 3:

After applying the quick-fix all tuples in your project will be migrated, and their usages, too. For example pairs will be replaced by usages of class Pair:

Tuples longer than tree do not have library analogs, so the quick-fix does not change them. As the error message suggests, use hand-written data classes:

Creating a data class takes only one line of code and makes reading easier with (supposedly) meaningful names: