File tree Expand file tree Collapse file tree 4 files changed +16
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 4 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ object Applications {
116116 if (sel.exists) sel :: tupleSelectors(n + 1 , tp) else Nil
117117 }
118118 def genTupleSelectors (n : Int , tp : Type ): List [Type ] = tp match {
119- case tp : AppliedType if ! tp.derivesFrom(defn. ProductClass ) && tp.derivesFrom(defn.PairClass ) =>
119+ case tp : AppliedType if ! defn.isTupleClass(tp.typeSymbol ) && tp.derivesFrom(defn.PairClass ) =>
120120 val List (head, tail) = tp.args
121121 head :: genTupleSelectors(n, tail)
122122 case _ => tupleSelectors(n, tp)
Original file line number Diff line number Diff line change @@ -1147,7 +1147,9 @@ class Typer extends Namer
11471147
11481148 val desugared =
11491149 if (protoFormals.length == 1 && params.length != 1 && ptIsCorrectProduct(protoFormals.head)) {
1150- val isGenericTuple = ! protoFormals.head.derivesFrom(defn.ProductClass )
1150+ val isGenericTuple =
1151+ protoFormals.head.derivesFrom(defn.TupleClass )
1152+ && ! defn.isTupleClass(protoFormals.head.typeSymbol)
11511153 desugar.makeTupledFunction(params, fnBody, isGenericTuple)
11521154 }
11531155 else {
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ object Tuple {
186186}
187187
188188/** Tuple of arbitrary non-zero arity */
189- sealed trait NonEmptyTuple extends Tuple {
189+ sealed trait NonEmptyTuple extends Tuple with Product {
190190 import Tuple ._
191191
192192 /** Get the i-th element of this tuple.
Original file line number Diff line number Diff line change 1+ @ main def Test = {
2+ val a : Product = 1 *: ()
3+ assert(a.productArity == 1 )
4+ val b : Product = 1 *: 2 *: ()
5+ assert(b.productArity == 2 )
6+ val c : Product = 1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: 23 *: 24 *: 25 *: ()
7+ assert(c.productArity == 25 )
8+ val d : NonEmptyTuple = (1 , 2 )
9+ val e : Product = d
10+ assert(e.productArity == 2 )
11+ }
You can’t perform that action at this time.
0 commit comments