@@ -635,6 +635,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
635
635
// There's a second trial where we try to instantiate all type variables in `qual.tpe.widen`,
636
636
// but that is done only after we search for extension methods or conversions.
637
637
typedSelect(tree, pt, qual)
638
+ else if defn.isSmallGenericTuple(qual.tpe) then
639
+ val elems = defn.tupleTypes(qual.tpe.widenTermRefExpr).getOrElse(Nil )
640
+ typedSelect(tree, pt, qual.cast(defn.tupleType(elems)))
638
641
else
639
642
val tree1 = tryExtensionOrConversion(
640
643
tree, pt, IgnoredProto (pt), qual, ctx.typerState.ownedVars, this , inSelect = true )
@@ -654,6 +657,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
654
657
if checkedType1.exists then
655
658
gadts.println(i " Member selection healed by GADT approximation " )
656
659
finish(tree1, qual1, checkedType1)
660
+ else if defn.isSmallGenericTuple(qual1.tpe) then
661
+ gadts.println(i " Tuple member selection healed by GADT approximation " )
662
+ typedSelect(tree, pt, qual1)
657
663
else
658
664
tryExtensionOrConversion(tree1, pt, IgnoredProto (pt), qual1, ctx.typerState.ownedVars, this , inSelect = true )
659
665
else EmptyTree
@@ -4010,15 +4016,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4010
4016
else err.typeMismatch(tree, pt, failure)
4011
4017
4012
4018
pt match
4013
- case pt : SelectionProto =>
4014
- if tree.tpe.derivesFrom(defn.PairClass ) && ! defn.isTupleNType(tree.tpe.widenDealias) then
4015
- // If this is a generic tuple we need to cast it to make the TupleN/ members accessible.
4016
- // This works only for generic tuples of known size up to 22.
4017
- defn.tupleTypes(tree.tpe.widenTermRefExpr) match
4018
- case Some (elems) if elems.length <= Definitions .MaxTupleArity =>
4019
- tree.cast(defn.tupleType(elems))
4020
- case _ => tree
4021
- else tree // other adaptations for selections are handled in typedSelect
4019
+ case _ : SelectionProto =>
4020
+ tree // adaptations for selections are handled in typedSelect
4022
4021
case _ if ctx.mode.is(Mode .ImplicitsEnabled ) && tree.tpe.isValueType =>
4023
4022
if pt.isRef(defn.AnyValClass , skipRefined = false )
4024
4023
|| pt.isRef(defn.ObjectClass , skipRefined = false )
0 commit comments