@@ -24,23 +24,23 @@ class SpecializeTuples extends MiniPhase:
24
24
override def transformApply (tree : Apply )(using Context ): Tree = tree match
25
25
case Apply (TypeApply (fun : NameTree , targs), args)
26
26
if fun.name == nme.apply && fun.symbol.exists && defn.isSpecializableTuple(fun.symbol.owner.companionClass, targs.map(_.tpe)) =>
27
- Apply (Select (New (defn.SpecialisedTuple (fun.symbol.owner.companionClass, targs.map(_.tpe)).typeRef), nme.CONSTRUCTOR ), args).withType(tree.tpe)
27
+ cpy. Apply (tree) (Select (New (defn.SpecialisedTuple (fun.symbol.owner.companionClass, targs.map(_.tpe)).typeRef), nme.CONSTRUCTOR ), args).withType(tree.tpe)
28
28
case Apply (TypeApply (fun : NameTree , targs), args)
29
29
if fun.name == nme.CONSTRUCTOR && fun.symbol.exists && defn.isSpecializableTuple(fun.symbol.owner, targs.map(_.tpe)) =>
30
- Apply (Select (New (defn.SpecialisedTuple (fun.symbol.owner, targs.map(_.tpe)).typeRef), nme.CONSTRUCTOR ), args).withType(tree.tpe)
30
+ cpy. Apply (tree) (Select (New (defn.SpecialisedTuple (fun.symbol.owner, targs.map(_.tpe)).typeRef), nme.CONSTRUCTOR ), args).withType(tree.tpe)
31
31
case _ => tree
32
32
end transformApply
33
33
34
34
override def transformSelect (tree : Select )(using Context ): Tree = tree match
35
- case Select (qual, nme._1) if qual.tpe.widen.match
36
- case AppliedType (tycon, args) => defn.isSpecializableTuple(tycon.classSymbol, args)
37
- case _ => false
35
+ case Select (qual, nme._1) if isAppliedSpecializableTuple(qual.tpe.widen)
38
36
=> Select (qual, nme._1.specializedName(qual.tpe.widen.argInfos.slice(0 , 1 )))
39
- case Select (qual, nme._2) if qual.tpe.widen.match
40
- case AppliedType (tycon, args) => defn.isSpecializableTuple(tycon.classSymbol, args)
41
- case _ => false
37
+ case Select (qual, nme._2) if isAppliedSpecializableTuple(qual.tpe.widen)
42
38
=> Select (qual, nme._2.specializedName(qual.tpe.widen.argInfos.slice(1 , 2 )))
43
39
case _ => tree
40
+
41
+ private def isAppliedSpecializableTuple (tp : Type )(using Context ) = tp match
42
+ case AppliedType (tycon, args) => defn.isSpecializableTuple(tycon.classSymbol, args)
43
+ case _ => false
44
44
end SpecializeTuples
45
45
46
46
object SpecializeTuples :
0 commit comments