Skip to content

Commit

Permalink
Adapt generic tuples to be able to access members
Browse files Browse the repository at this point in the history
Fixes #14215
  • Loading branch information
nicolasstucki committed Jan 10, 2022
1 parent ec43a19 commit b66650b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3854,6 +3854,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
gadts.println(i"Member selection healed by GADT approximation")
tree.cast(gadtApprox)
else tree
else if tree.tpe.derivesFrom(defn.PairClass) && !defn.isTupleNType(tree.tpe.widenDealias) then
// If this is a generic tuple we need to cast it to make the TupleN/ members accessible.
// This only works for generic tuples of know size up to 22.
defn.tupleTypes(tree.tpe.widenTermRefExpr, Definitions.MaxTupleArity) match
case Some(elems) => tree.cast(defn.tupleType(elems))
case None => tree
else tree // other adaptations for selections are handled in typedSelect
case _ if ctx.mode.is(Mode.ImplicitsEnabled) && tree.tpe.isValueType =>
checkConversionsSpecific(pt, tree.srcPos)
Expand Down

0 comments on commit b66650b

Please sign in to comment.