@@ -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
@@ -3998,15 +4004,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3998
4004
else err.typeMismatch(tree, pt, failure)
3999
4005
4000
4006
pt match
4001
- case pt : SelectionProto =>
4002
- if tree.tpe.derivesFrom(defn.PairClass ) && ! defn.isTupleNType(tree.tpe.widenDealias) then
4003
- // If this is a generic tuple we need to cast it to make the TupleN/ members accessible.
4004
- // This works only for generic tuples of known size up to 22.
4005
- defn.tupleTypes(tree.tpe.widenTermRefExpr) match
4006
- case Some (elems) if elems.length <= Definitions .MaxTupleArity =>
4007
- tree.cast(defn.tupleType(elems))
4008
- case _ => tree
4009
- else tree // other adaptations for selections are handled in typedSelect
4007
+ case _ : SelectionProto =>
4008
+ tree // adaptations for selections are handled in typedSelect
4010
4009
case _ if ctx.mode.is(Mode .ImplicitsEnabled ) && tree.tpe.isValueType =>
4011
4010
if pt.isRef(defn.AnyValClass , skipRefined = false )
4012
4011
|| pt.isRef(defn.ObjectClass , skipRefined = false )
0 commit comments