Last active
August 13, 2019 16:51
-
-
Save milessabin/a684a84b6aa2e85b9508d7a672b7cb71 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tupleType(tpes: List[Type]): Type = { | |
val PairType = typeOf[_ *: _] match { | |
case Type.IsAppliedType(tp) => tp.tycon | |
} | |
@tailrec | |
def nestedPairs(tpes: List[Type], acc: Type): Type = tpes match { | |
case Nil => acc | |
case hd :: tail => nestedPairs(tail, Type.AppliedType(PairType, List(hd, acc))) | |
} | |
tpes.length match { | |
case 0 => defn.UnitType | |
case n if n <= 22 => Type.AppliedType(defn.TupleClass(n).asClassDef /* what goes here? */, tpes) | |
case n => nestedPairs(tpes.reverse, defn.UnitType) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment