File tree 5 files changed +6
-19
lines changed
compiler/src/dotty/tools/dotc
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 @@ -508,7 +508,6 @@ class Definitions {
508
508
def DynamicClass (implicit ctx : Context ) = DynamicType .symbol.asClass
509
509
lazy val OptionType : TypeRef = ctx.requiredClassRef(" scala.Option" )
510
510
def OptionClass (implicit ctx : Context ) = OptionType .symbol.asClass
511
- lazy val NameBasedPatternType : TypeRef = ctx.requiredClassRef(" scala.NameBasedPattern" )
512
511
lazy val ProductType : TypeRef = ctx.requiredClassRef(" scala.Product" )
513
512
def ProductClass (implicit ctx : Context ) = ProductType .symbol.asClass
514
513
lazy val Product_canEqualR = ProductClass .requiredMethodRef(nme.canEqual_)
@@ -794,15 +793,8 @@ class Definitions {
794
793
TupleType (elems.size).appliedTo(elems)
795
794
}
796
795
797
- /** Is this type eligible for name based pattern matching?
798
- *
799
- * That means either extending `scala.ProductN` OR `NameBasedPattern`.
800
- * In the long term, we can remove the first condition by having
801
- * `scala.ProductN` inherit `NameBasedPattern`.
802
- */
803
796
def isNameBasedPatternSubType (tp : Type )(implicit ctx : Context ) =
804
- (tp.derivesFrom(ProductType .symbol) && tp.baseClasses.exists(isProductClass)) ||
805
- tp.derivesFrom(NameBasedPatternType .symbol)
797
+ tp.derivesFrom(ProductType .symbol)
806
798
807
799
/** Is `tp` (an alias) of either a scala.FunctionN or a scala.ImplicitFunctionN? */
808
800
def isFunctionType (tp : Type )(implicit ctx : Context ) = {
Original file line number Diff line number Diff line change @@ -184,7 +184,6 @@ object StdNames {
184
184
final val Function : N = " Function"
185
185
final val ImplicitFunction : N = " ImplicitFunction"
186
186
final val Mirror : N = " Mirror"
187
- final val NameBasedPattern : N = " NameBasedPattern"
188
187
final val Nothing : N = " Nothing"
189
188
final val Null : N = " Null"
190
189
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