File tree Expand file tree Collapse file tree 5 files changed +6
-19
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 5 files changed +6
-19
lines changed Original file line number Diff line number Diff line change @@ -414,10 +414,10 @@ object desugar {
414
414
if (arity > Definitions .MaxTupleArity ) scalaDot(nme.Product .toTypeName)
415
415
else productConstr(arity)
416
416
417
- // Case classes and case objects get NameBasedPattern and Product/ProductN parents
417
+ // Case classes and case objects get Product/ProductN parents
418
418
val parents1 : List [Tree ] =
419
419
if (mods.is(Case ))
420
- parents :+ product :+ scalaDot(nme. NameBasedPattern .toTypeName)
420
+ parents :+ product
421
421
else parents
422
422
423
423
// The thicket which is the desugared version of the companion object
Original file line number Diff line number Diff line change @@ -513,7 +513,6 @@ class Definitions {
513
513
def DynamicClass (implicit ctx : Context ) = DynamicType .symbol.asClass
514
514
lazy val OptionType : TypeRef = ctx.requiredClassRef(" scala.Option" )
515
515
def OptionClass (implicit ctx : Context ) = OptionType .symbol.asClass
516
- lazy val NameBasedPatternType : TypeRef = ctx.requiredClassRef(" scala.NameBasedPattern" )
517
516
lazy val ProductType : TypeRef = ctx.requiredClassRef(" scala.Product" )
518
517
def ProductClass (implicit ctx : Context ) = ProductType .symbol.asClass
519
518
lazy val Product_canEqualR = ProductClass .requiredMethodRef(nme.canEqual_)
@@ -841,15 +840,8 @@ class Definitions {
841
840
TupleType (elems.size).appliedTo(elems)
842
841
}
843
842
844
- /** Is this type eligible for name based pattern matching?
845
- *
846
- * That means either extending `scala.ProductN` OR `NameBasedPattern`.
847
- * In the long term, we can remove the first condition by having
848
- * `scala.ProductN` inherit `NameBasedPattern`.
849
- */
850
843
def isNameBasedPatternSubType (tp : Type )(implicit ctx : Context ) =
851
- (tp.derivesFrom(ProductType .symbol) && tp.baseClasses.exists(isProductClass)) ||
852
- tp.derivesFrom(NameBasedPatternType .symbol)
844
+ tp.derivesFrom(ProductType .symbol)
853
845
854
846
/** Is `tp` (an alias) of either a scala.FunctionN or a scala.ImplicitFunctionN? */
855
847
def isFunctionType (tp : Type )(implicit ctx : Context ) = {
Original file line number Diff line number Diff line change @@ -186,7 +186,6 @@ object StdNames {
186
186
final val Function : N = " Function"
187
187
final val ImplicitFunction : N = " ImplicitFunction"
188
188
final val Mirror : N = " Mirror"
189
- final val NameBasedPattern : N = " NameBasedPattern"
190
189
final val Nothing : N = " Nothing"
191
190
final val Null : N = " Null"
192
191
final val Object : N = " Object"
Original file line number Diff line number Diff line change @@ -51,11 +51,11 @@ object Applications {
51
51
* type for a pattern with `numArgs` subpatterns.
52
52
*
53
53
* This is the case if:
54
- * - `tp` is a subtype of the Product<numArgs> class or `NameBasedPattern` trait
54
+ * - `tp` is a subtype of the Product trait
55
55
* - `tp` has members `_1` to `_N` where `N == numArgs`
56
56
*/
57
- def isNameBasedMatch (tp : Type , numArgs : Int )(implicit ctx : Context ) =
58
- 0 <= numArgs && defn.isNameBasedPatternSubType (tp) &&
57
+ def isProductMatch (tp : Type , numArgs : Int )(implicit ctx : Context ) =
58
+ numArgs > 0 && defn.isProductSubType (tp) &&
59
59
productSelectorTypes(tp).size == numArgs
60
60
61
61
/** Does `tp` fit the "get match" conditions as an unapply result type?
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments