scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Different type sizes for TupleN vs nested pairs encoding

Open mbovel opened this issue 1 day ago • 1 comments

package dotty.tools.dotc.core

import dotty.tools.DottyTest
import dotty.tools.dotc.core.Symbols.defn
import dotty.tools.dotc.core.TypeOps

import org.junit.Test
import org.junit.Assert.assertEquals

class TypesTest extends DottyTest:

  @Test def tuple3TypeSize =
    val tpe = defn.TupleType(3).nn.appliedTo(List(defn.IntType, defn.BooleanType, defn.DoubleType))
    assertEquals(3, tpe.typeSize) // false,  tpe.typeSize == 1 🤔

  @Test def tuple3ConsTypeSize =
    val tpe = TypeOps.nestedPairs(List(defn.IntType, defn.BooleanType, defn.DoubleType))
    assertEquals(3, tpe.typeSize)

Shouldn't the size of a 3-tuple always be 3, whereas it is encoded with a Tuple3 type application or with nested pairs?

mbovel avatar Dec 11 '25 10:12 mbovel