At first glance NamedTuple
with Selectable
combination seems fine.
But after some closer consideration. NamedTuples
just break the structural typeing nature of Selectable
.
class Record extends Selectable {
def selectDynamic(x: String) = 1
}
type R1 = Record { def f1: Int; def f2: Int }
type R2 = Record { def f2: Int; def f1: Int }
type R3 = Record { def f1: Int }
type R11 = Record { type Fields = (f1: Int, f2: Int) }
type R12 = Record { type Fields = (f2: Int, f1: Int) }
summon[R1 =:= R2] // Yes
summon[R1 <:< R3] // Yes
summon[R1 =:= R11] // No
summon[R11 =:= R12] // No
Is this intentional design or an implementation limitation?