Skip to content

Commit 721cc47

Browse files
Revert name change on isProductMatch & isProductSubType
1 parent b591563 commit 721cc47

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

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

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

14311431
def resultInMonad =
14321432
if (aligner.isBool) defn.UnitType
1433-
else if (isNameBasedMatch(resultType, aligner.prodArity)) resultType
1433+
else if (isProductMatch(resultType, aligner.prodArity)) resultType
14341434
else if (isGetMatch(resultType)) extractorMemberType(resultType, nme.get)
14351435
else resultType
14361436

@@ -1474,7 +1474,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
14741474
protected def seqTree(binder: Symbol) = tupleSel(binder)(firstIndexingBinder + 1)
14751475
protected def tupleSel(binder: Symbol)(i: Int): Tree = {
14761476
val accessors =
1477-
if (defn.isNameBasedPatternSubType(binder.info))
1477+
if (defn.isProductSubType(binder.info))
14781478
productSelectors(binder.info)
14791479
else binder.caseAccessors
14801480
val res =
@@ -1631,7 +1631,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
16311631
ref(binder) :: Nil
16321632
}
16331633
else if ((aligner.isSingle && aligner.extractor.prodArity == 1) &&
1634-
!isNameBasedMatch(binderTypeTested, aligner.prodArity) && isGetMatch(binderTypeTested))
1634+
!isProductMatch(binderTypeTested, aligner.prodArity) && isGetMatch(binderTypeTested))
16351635
List(ref(binder))
16361636
else
16371637
subPatRefs(binder)
@@ -1882,11 +1882,11 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {
18821882

18831883
val expanded: List[Type] = /*(
18841884
if (result =:= defn.BooleanType) Nil
1885-
else if (defn.isNameBasedPatternSubType(result)) productSelectorTypes(result)
1885+
else if (defn.isProductSubType(result)) productSelectorTypes(result)
18861886
else if (result.classSymbol is Flags.CaseClass) result.decls.filter(x => x.is(Flags.CaseAccessor) && x.is(Flags.Method)).map(_.info).toList
18871887
else result.select(nme.get) :: Nil
18881888
)*/
1889-
if (isNameBasedMatch(resultType, args.length)) productSelectorTypes(resultType)
1889+
if (isProductMatch(resultType, args.length)) productSelectorTypes(resultType)
18901890
else if (isGetMatch(resultType)) getUnapplySelectors(resultOfGet, args)
18911891
else if (resultType isRef defn.BooleanClass) Nil
18921892
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
@@ -747,7 +747,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
747747
/** Is `formal` a product type which is elementwise compatible with `params`? */
748748
def ptIsCorrectProduct(formal: Type) = {
749749
isFullyDefined(formal, ForceDegree.noBottom) &&
750-
defn.isNameBasedPatternSubType(formal) &&
750+
defn.isProductSubType(formal) &&
751751
Applications.productSelectorTypes(formal).corresponds(params) {
752752
(argType, param) =>
753753
param.tpt.isEmpty || argType <:< typedAheadType(param.tpt).tpe

0 commit comments

Comments
 (0)