File tree 4 files changed +16
-3
lines changed
compiler/src/dotty/tools/dotc/typer
4 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ object Applications {
116
116
if (sel.exists) sel :: tupleSelectors(n + 1 , tp) else Nil
117
117
}
118
118
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 ) =>
120
120
val List (head, tail) = tp.args
121
121
head :: genTupleSelectors(n, tail)
122
122
case _ => tupleSelectors(n, tp)
Original file line number Diff line number Diff line change @@ -1147,7 +1147,9 @@ class Typer extends Namer
1147
1147
1148
1148
val desugared =
1149
1149
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)
1151
1153
desugar.makeTupledFunction(params, fnBody, isGenericTuple)
1152
1154
}
1153
1155
else {
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ object Tuple {
186
186
}
187
187
188
188
/** Tuple of arbitrary non-zero arity */
189
- sealed trait NonEmptyTuple extends Tuple {
189
+ sealed trait NonEmptyTuple extends Tuple with Product {
190
190
import Tuple ._
191
191
192
192
/** 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