File tree 2 files changed +12
-3
lines changed
compiler/src/dotty/tools/dotc 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -1074,7 +1074,7 @@ class Definitions {
1074
1074
}
1075
1075
1076
1076
def isProductSubType (tp : Type )(implicit ctx : Context ): Boolean =
1077
- tp.derivesFrom(ProductType .symbol)
1077
+ tp.derivesFrom(ProductType .symbol) || tp.derivesFrom( PairClass )
1078
1078
1079
1079
/** Is `tp` (an alias) of either a scala.FunctionN or a scala.ImplicitFunctionN
1080
1080
* instance?
Original file line number Diff line number Diff line change @@ -59,8 +59,17 @@ object Applications {
59
59
extractorMemberType(tp, nme.get, errorPos).exists
60
60
61
61
def productSelectorTypes (tp : Type , errorPos : Position = NoPosition )(implicit ctx : Context ): List [Type ] = {
62
- val sels = for (n <- Iterator .from(0 )) yield extractorMemberType(tp, nme.selectorName(n), errorPos)
63
- sels.takeWhile(_.exists).toList
62
+ def tupleSelectors (n : Int , tp : Type ): List [Type ] = {
63
+ val sel = extractorMemberType(tp, nme.selectorName(n), errorPos)
64
+ if (sel.exists) sel :: tupleSelectors(n + 1 , tp) else Nil
65
+ }
66
+ def genTupleSelectors (n : Int , tp : Type ): List [Type ] = tp match {
67
+ case tp : AppliedType if ! tp.derivesFrom(defn.ProductClass ) && tp.derivesFrom(defn.PairClass ) =>
68
+ val List (head, tail) = tp.args
69
+ head :: genTupleSelectors(n, tail)
70
+ case _ => tupleSelectors(n, tp)
71
+ }
72
+ genTupleSelectors(0 , tp)
64
73
}
65
74
66
75
def productArity (tp : Type )(implicit ctx : Context ): Int =
You can’t perform that action at this time.
0 commit comments