File tree Expand file tree Collapse file tree 3 files changed +7
-12
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -797,15 +797,11 @@ class Definitions {
797797 }
798798
799799 def isProductSubType (tp : Type )(implicit ctx : Context ) =
800- (tp derivesFrom ProductType .symbol) && tp.baseClasses.exists(isProductClass)
800+ (tp.derivesFrom(ProductType .symbol) && tp.baseClasses.exists(isProductClass)) ||
801+ tp.derivesFrom(NameBasedPatternType .symbol)
801802
802803 def productArity (tp : Type )(implicit ctx : Context ) =
803- if (tp derivesFrom ProductType .symbol)
804- tp.baseClasses.find(isProductClass) match {
805- case Some (prod) => prod.typeParams.length
806- case None => - 1
807- }
808- else - 1
804+ if (isProductSubType(tp)) typer.Applications .productSelectorTypes(tp).size else - 1
809805
810806 /** Is `tp` (an alias) of either a scala.FunctionN or a scala.ImplicitFunctionN ? */
811807 def isFunctionType (tp : Type )(implicit ctx : Context ) = {
Original file line number Diff line number Diff line change @@ -52,8 +52,8 @@ object Applications {
5252 * This is the case of `tp` is a subtype of the Product<numArgs> class.
5353 */
5454 def isProductMatch (tp : Type , numArgs : Int )(implicit ctx : Context ) =
55- 0 <= numArgs && numArgs <= Definitions . MaxTupleArity &&
56- tp.derivesFrom(defn. ProductNType (numArgs).typeSymbol)
55+ 0 <= numArgs && defn.isProductSubType(tp) &&
56+ productSelectorTypes(tp).size == numArgs
5757
5858 /** Does `tp` fit the "get match" conditions as an unapply result type?
5959 * This is the case of `tp` has a `get` member as well as a
Original file line number Diff line number Diff line change @@ -746,10 +746,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
746746
747747 /** Is `formal` a product type which is elementwise compatible with `params`? */
748748 def ptIsCorrectProduct (formal : Type ) = {
749- val pclass = defn.ProductNType (params.length).symbol
750749 isFullyDefined(formal, ForceDegree .noBottom) &&
751- formal.derivesFrom(pclass) &&
752- formal.baseArgTypes(pclass ).corresponds(params) {
750+ defn.isProductSubType(formal) &&
751+ Applications .productSelectorTypes(formal ).corresponds(params) {
753752 (argType, param) =>
754753 param.tpt.isEmpty || argType <:< typedAheadType(param.tpt).tpe
755754 }
You can’t perform that action at this time.
0 commit comments