Skip to content

Commit df7d123

Browse files
Revert name change on isProductMatch & isProductSubType
1 parent 01a9bf2 commit df7d123

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ class Definitions {
840840
TupleType(elems.size).appliedTo(elems)
841841
}
842842

843-
def isNameBasedPatternSubType(tp: Type)(implicit ctx: Context) =
843+
def isProductSubType(tp: Type)(implicit ctx: Context) =
844844
tp.derivesFrom(ProductType.symbol)
845845

846846
/** Is `tp` (an alias) of either a scala.FunctionN or a scala.ImplicitFunctionN? */

compiler/src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
234234
// returns MatchMonad[U]
235235
def flatMap(prev: Tree, b: Symbol, next: Tree): Tree = {
236236
val resultArity = productArity(b.info)
237-
if (isNameBasedMatch(prev.tpe, resultArity)) {
237+
if (isProductMatch(prev.tpe, resultArity)) {
238238
val nullCheck: Tree = prev.select(defn.Object_ne).appliedTo(Literal(Constant(null)))
239239
ifThenElseZero(
240240
nullCheck,
@@ -1426,7 +1426,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
14261426

14271427
def resultInMonad =
14281428
if (aligner.isBool) defn.UnitType
1429-
else if (isNameBasedMatch(resultType, aligner.prodArity)) resultType
1429+
else if (isProductMatch(resultType, aligner.prodArity)) resultType
14301430
else if (isGetMatch(resultType)) extractorMemberType(resultType, nme.get)
14311431
else resultType
14321432

@@ -1470,7 +1470,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
14701470
protected def seqTree(binder: Symbol) = tupleSel(binder)(firstIndexingBinder + 1)
14711471
protected def tupleSel(binder: Symbol)(i: Int): Tree = {
14721472
val accessors =
1473-
if (defn.isNameBasedPatternSubType(binder.info))
1473+
if (defn.isProductSubType(binder.info))
14741474
productSelectors(binder.info)
14751475
else binder.caseAccessors
14761476
val res =
@@ -1627,7 +1627,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
16271627
ref(binder) :: Nil
16281628
}
16291629
else if ((aligner.isSingle && aligner.extractor.prodArity == 1) &&
1630-
!isNameBasedMatch(binderTypeTested, aligner.prodArity) && isGetMatch(binderTypeTested))
1630+
!isProductMatch(binderTypeTested, aligner.prodArity) && isGetMatch(binderTypeTested))
16311631
List(ref(binder))
16321632
else
16331633
subPatRefs(binder)
@@ -1878,11 +1878,11 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
18781878

18791879
val expanded: List[Type] = /*(
18801880
if (result =:= defn.BooleanType) Nil
1881-
else if (defn.isNameBasedPatternSubType(result)) productSelectorTypes(result)
1881+
else if (defn.isProductSubType(result)) productSelectorTypes(result)
18821882
else if (result.classSymbol is Flags.CaseClass) result.decls.filter(x => x.is(Flags.CaseAccessor) && x.is(Flags.Method)).map(_.info).toList
18831883
else result.select(nme.get) :: Nil
18841884
)*/
1885-
if (isNameBasedMatch(resultType, args.length)) productSelectorTypes(resultType)
1885+
if (isProductMatch(resultType, args.length)) productSelectorTypes(resultType)
18861886
else if (isGetMatch(resultType)) getUnapplySelectors(resultOfGet, args)
18871887
else if (resultType isRef defn.BooleanClass) Nil
18881888
else {

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ object Applications {
7272
}
7373

7474
def productArity(tp: Type)(implicit ctx: Context) =
75-
if (defn.isNameBasedPatternSubType(tp)) productSelectorTypes(tp).size else -1
75+
if (defn.isProductSubType(tp)) productSelectorTypes(tp).size else -1
7676

7777
def productSelectors(tp: Type)(implicit ctx: Context): List[Symbol] = {
7878
val sels = for (n <- Iterator.from(0)) yield tp.member(nme.selectorName(n)).symbol
@@ -108,13 +108,13 @@ object Applications {
108108
}
109109
else {
110110
assert(unapplyName == nme.unapply)
111-
if (isNameBasedMatch(unapplyResult, args.length))
111+
if (isProductMatch(unapplyResult, args.length))
112112
productSelectorTypes(unapplyResult)
113113
else if (isGetMatch(unapplyResult, pos))
114114
getUnapplySelectors(getTp, args, pos)
115115
else if (unapplyResult isRef defn.BooleanClass)
116116
Nil
117-
else if (defn.isNameBasedPatternSubType(unapplyResult))
117+
else if (defn.isProductSubType(unapplyResult))
118118
productSelectorTypes(unapplyResult)
119119
// this will cause a "wrong number of arguments in pattern" error later on,
120120
// which is better than the message in `fail`.

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
762762
/** Is `formal` a product type which is elementwise compatible with `params`? */
763763
def ptIsCorrectProduct(formal: Type) = {
764764
isFullyDefined(formal, ForceDegree.noBottom) &&
765-
defn.isNameBasedPatternSubType(formal) &&
765+
defn.isProductSubType(formal) &&
766766
Applications.productSelectorTypes(formal).corresponds(params) {
767767
(argType, param) =>
768768
param.tpt.isEmpty || argType <:< typedAheadType(param.tpt).tpe

0 commit comments

Comments
 (0)